Skip to content

Instantly share code, notes, and snippets.

@xolian
Created October 11, 2021 16:16
Show Gist options
  • Select an option

  • Save xolian/6afbd5f79b5249ce77a24196e075baf3 to your computer and use it in GitHub Desktop.

Select an option

Save xolian/6afbd5f79b5249ce77a24196e075baf3 to your computer and use it in GitHub Desktop.

Revisions

  1. xolian renamed this gist Oct 11, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. xolian created this gist Oct 11, 2021.
    18 changes: 18 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    [Uploading to S3 in sh](https://tmont.com/blargh/2014/1/uploading-to-s3-in-bash)
    ```
    file=/path/to/file/to/upload.tar.gz
    bucket=your-bucket
    resource="/${bucket}/${file}"
    contentType="application/x-compressed-tar"
    dateValue=`date -R`
    stringToSign="PUT\n\n${contentType}\n${dateValue}\n${resource}"
    s3Key=xxxxxxxxxxxxxxxxxxxx
    s3Secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    signature=`echo -en ${stringToSign} | openssl sha1 -hmac ${s3Secret} -binary | base64`
    curl -X PUT -T "${file}" \
    -H "Host: ${bucket}.s3.amazonaws.com" \
    -H "Date: ${dateValue}" \
    -H "Content-Type: ${contentType}" \
    -H "Authorization: AWS ${s3Key}:${signature}" \
    https://${bucket}.s3.amazonaws.com/${file}
    ```