Last active
          May 30, 2023 16:59 
        
      - 
      
 - 
        
Save sh1n0b1/f4ed6b341e86cf8a03950618e70e5ed2 to your computer and use it in GitHub Desktop.  
Revisions
- 
        
sh1n0b1 revised this gist
Aug 26, 2016 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,12 +2,17 @@ # This is how I upload my new Sol Trader builds (http://soltrader.net) # Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash # ==================================================================================== # Aug 25, 2016 sh1n0b1 # Modified this script to support AWS session token # More work will be done on this. # # S3KEY="ASIAJLFN####################" # S3SECRET="4gacEIX5s/ZTyLT+0K################" # S3SESSION="FQoDYXdzELT//////////###########################################" # ==================================================================================== S3KEY="" S3SECRET="" S3SESSION=""  - 
        
sh1n0b1 revised this gist
Aug 26, 2016 . 1 changed file with 76 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,14 +2,10 @@ # This is how I upload my new Sol Trader builds (http://soltrader.net) # Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash # # S3KEY="ASIAJLFN####################" # S3SECRET="4gacEIX5s/ZTyLT+0K################" # pass these in # S3SESSION="FQoDYXdzELT//////////###########################################" # ==================================================================================== S3KEY="" @@ -30,7 +26,7 @@ function putS3 string="PUT\n\n$content_type\n$date\n$acl\n$token\n/$bucket$aws_path$file" signature=$(echo -en "${string}" | openssl sha1 -hmac "${S3SECRET}" -binary | base64) # Executing # curl -v -X PUT -T "$path/$file" \ # -H "Host: $bucket.s3.amazonaws.com" \ # -H "Date: $date" \ @@ -51,8 +47,77 @@ function putS3 echo " \"https://$bucket.s3.amazonaws.com$aws_path$file\"" } function getObject { bucket=$1 filepath=$2 date=$(date +"%a, %d %b %Y %T %z") acl="x-amz-acl:public-read" content_type='application/x-compressed-tar' token="x-amz-security-token:"${S3SESSION} string="GET\n\n$content_type\n$date\n$acl\n$token\n/$bucket$filepath" signature=$(echo -en "${string}" | openssl sha1 -hmac "${S3SECRET}" -binary | base64) # #Executing # curl -v -X GET \ # -H "Host: $bucket.s3.amazonaws.com" \ # -H "Date: $date" \ # -H "Content-Type: $content_type" \ # -H "$acl" \ # -H "$token" \ # -H "Authorization: AWS ${S3KEY}:$signature" \ # "https://$bucket.s3.amazonaws.com$filepath" # Print the curl command echo "curl -v -X GET \\" echo " -H \"Host: $bucket.s3.amazonaws.com\" \\" echo " -H \"Date: $date\" \\" echo " -H \"Content-Type: $content_type\" \\" echo " -H \"$acl\" \\" echo " -H \"$token\" \\" echo " -H \"Authorization: AWS ${S3KEY}:$signature\" \\" echo " \"https://$bucket.s3.amazonaws.com$filepath\"" } function listBucket { bucket=$1 filepath=$2 date=$(date +"%a, %d %b %Y %T %z") acl="x-amz-acl:public-read" content_type='application/x-compressed-tar' token="x-amz-security-token:"${S3SESSION} string="GET\n\n$content_type\n$date\n$acl\n$token\n/$bucket$filepath" signature=$(echo -en "${string}" | openssl sha1 -hmac "${S3SECRET}" -binary | base64) # #Executing # curl -v -X GET \ # -H "Host: $bucket.s3.amazonaws.com" \ # -H "Date: $date" \ # -H "Content-Type: $content_type" \ # -H "$acl" \ # -H "$token" \ # -H "Authorization: AWS ${S3KEY}:$signature" \ # "https://$bucket.s3.amazonaws.com$filepath?list-type=2" # Print the curl command echo "curl -v -X GET \\" echo " -H \"Host: $bucket.s3.amazonaws.com\" \\" echo " -H \"Date: $date\" \\" echo " -H \"Content-Type: $content_type\" \\" echo " -H \"$acl\" \\" echo " -H \"$token\" \\" echo " -H \"Authorization: AWS ${S3KEY}:$signature\" \\" echo " \"https://$bucket.s3.amazonaws.com$filepath?list-type=2\"" } # ==================================================================================== # putS3 "bucket_name" "/local_filepath" "upload_file.txt" "/s3_dir" # Just replace the parameters above^ # ==================================================================================== # ==================================================================================== # getObject "bucket_name" "/file_path.txt" # ==================================================================================== # ==================================================================================== #listBucket "bucket_name" "/dir" # ====================================================================================  - 
        
sh1n0b1 revised this gist
Aug 26, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ # More work will be done on this. # #S3KEY="ASIAJLFN####################" #S3SECRET="4gacEIX5s/ZTyLT+0K################" #S3SESSION="FQoDYXdzELT//////////###########################################" # ==================================================================================== @@ -30,7 +30,7 @@ function putS3 string="PUT\n\n$content_type\n$date\n$acl\n$token\n/$bucket$aws_path$file" signature=$(echo -en "${string}" | openssl sha1 -hmac "${S3SECRET}" -binary | base64) # Execute # curl -v -X PUT -T "$path/$file" \ # -H "Host: $bucket.s3.amazonaws.com" \ # -H "Date: $date" \  - 
        
sh1n0b1 created this gist
Aug 26, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ # You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine # This is how I upload my new Sol Trader builds (http://soltrader.net) # Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash # ==================================================================================== # Aug 25, 2016 sh1n0b1 # Modified this script to support AWS session token # More work will be done on this. # #S3KEY="ASIAJLFN####################" #S3SECRET="4gacEIX5s/ZTyLT+0K################" # pass these in #S3SESSION="FQoDYXdzELT//////////###########################################" # ==================================================================================== S3KEY="" S3SECRET="" S3SESSION="" # No need to modify the function below: function putS3 { bucket=$1 path=$2 file=$3 aws_path=$4 date=$(date +"%a, %d %b %Y %T %z") acl="x-amz-acl:public-read" content_type='application/x-compressed-tar' token="x-amz-security-token:"${S3SESSION} string="PUT\n\n$content_type\n$date\n$acl\n$token\n/$bucket$aws_path$file" signature=$(echo -en "${string}" | openssl sha1 -hmac "${S3SECRET}" -binary | base64) # Executing # curl -v -X PUT -T "$path/$file" \ # -H "Host: $bucket.s3.amazonaws.com" \ # -H "Date: $date" \ # -H "Content-Type: $content_type" \ # -H "$acl" \ # -H "$token" \ # -H "Authorization: AWS ${S3KEY}:$signature" \ # "https://$bucket.s3.amazonaws.com$aws_path$file" # Print the curl command echo "curl -v -X PUT -T \"$path/$file\" \\" echo " -H \"Host: $bucket.s3.amazonaws.com\" \\" echo " -H \"Date: $date\" \\" echo " -H \"Content-Type: $content_type\" \\" echo " -H \"$acl\" \\" echo " -H \"$token\" \\" echo " -H \"Authorization: AWS ${S3KEY}:$signature\" \\" echo " \"https://$bucket.s3.amazonaws.com$aws_path$file\"" } # ==================================================================================== putS3 "bucket_name" "/local_dir/" "local_file.txt" "/s3_local_path/" # Just replace the parameters above^ # putS3 "storage_bucket" "~/Desktop/" "upload_file.txt" "/folder" # ====================================================================================