Last active
          November 22, 2017 14:00 
        
      - 
      
- 
        Save krasnuydyx/81206cad224207bb7245908815a75385 to your computer and use it in GitHub Desktop. 
    AWS S3 console upload/download/delete
  
        
  
    
      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 characters
    
  
  
    
  | S3KEY="" | |
| BUCKET="" | |
| REGION="s3" | |
| S3SECRET="" | |
| file=$1 | |
| resource="/${BUCKET}/${file}" | |
| contentType="application/x-compressed-tar" | |
| dateValue=`date -R` | |
| stringToSign="DELETE\n\n${contentType}\n${dateValue}\n${resource}" | |
| echo "DELETING FROM S3" | |
| signature=`echo -en ${stringToSign} | openssl sha1 -hmac ${S3SECRET} -binary | base64` | |
| curl -X DELETE \ | |
| -H "Host: ${BUCKET}.${REGION}.amazonaws.com" \ | |
| -H "Date: ${dateValue}" \ | |
| -H "Content-Type: ${contentType}" \ | |
| -H "Authorization: AWS ${S3KEY}:${signature}" \ | |
| https://${BUCKET}.${REGION}.amazonaws.com/${file} | 
  
    
      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 characters
    
  
  
    
  | S3KEY="" | |
| BUCKET="" | |
| REGION="s3" | |
| S3SECRET="" | |
| file=$1 | |
| resource="/${BUCKET}/${file}" | |
| contentType="application/x-compressed-tar" | |
| dateValue=`date -R` | |
| stringToSign="GET\n\n${contentType}\n${dateValue}\n${resource}" | |
| echo "DOWNLOADING FROM S3" | |
| signature=`echo -en ${stringToSign} | openssl sha1 -hmac ${S3SECRET} -binary | base64` | |
| curl -o ${file} \ | |
| -H "Host: ${BUCKET}.${REGION}.amazonaws.com" \ | |
| -H "Date: ${dateValue}" \ | |
| -H "Content-Type: ${contentType}" \ | |
| -H "Authorization: AWS ${S3KEY}:${signature}" \ | |
| https://${BUCKET}.${REGION}.amazonaws.com/${file} | 
  
    
      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 characters
    
  
  
    
  | S3KEY="" | |
| BUCKET="" | |
| REGION="s3" | |
| S3SECRET="" | |
| file=$1 | |
| resource="/${BUCKET}/${file}" | |
| contentType="application/x-compressed-tar" | |
| dateValue=`date -R` | |
| stringToSign="PUT\n\n${contentType}\n${dateValue}\n${resource}" | |
| echo "SENDING TO S3" | |
| signature=`echo -en ${stringToSign} | openssl sha1 -hmac ${S3SECRET} -binary | base64` | |
| curl -X PUT -T "${file}" \ | |
| -H "Host: ${BUCKET}.${REGION}.amazonaws.com" \ | |
| -H "Date: ${dateValue}" \ | |
| -H "Content-Type: ${contentType}" \ | |
| -H "Authorization: AWS ${S3KEY}:${signature}" \ | |
| https://${BUCKET}.${REGION}.amazonaws.com/${file} | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment