Forked from ElanHasson/libstorj upload files to bucket and overwrite
Last active
October 9, 2019 13:35
-
-
Save AlexeyALeonov/b08e79f18ec1e4ac5ce83f0af1a389f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Simple Uploader for linux. Place inside libstorj/bin | |
# The script will create a new directory with randomly generated files, and begin uploading | |
# Files are automatically removed after uploading. | |
BUCKET=a882a4d1af7ce8a3bf6674c1 | |
. ~/.storj. | |
#generates a 16 character unique filename | |
FILENAME=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16 ; echo '') | |
#Create Directory to store files in | |
mkdir upload_files | |
FILENAME="upload_files/$FILENAME" | |
logfile="upload_log.log" | |
echo File name $FILENAME | |
echo > $logfile | |
#creates a 1 gig file. Modify to your suiting | |
#dd if=/dev/urandom of=$FILENAME bs=1024 count=1M | |
#alternatively, openssl is a faster option | |
openssl rand -out $FILENAME -base64 $(( 2**30 * 3/4 )) | |
while : | |
do | |
echo Bucket: $BUCKET | |
echo Bucket: $BUCKET >> $logfile | |
#change the hash by adding a character | |
echo a >> $FILENAME | |
storj upload-file -d $BUCKET $FILENAME >> $logfile | |
cat $logfile | |
FILE_ID=$(tail $logfile | grep -o -w '\w\{24\}') | |
echo File ID: $FILE_ID | |
storj remove-file $BUCKET $FILE_ID | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment