Skip to content

Instantly share code, notes, and snippets.

@neochar
Forked from PhilipSchmid/minio-upload.sh
Last active December 6, 2021 08:03
Show Gist options
  • Select an option

  • Save neochar/bd7319b597da818cddf043488ec23719 to your computer and use it in GitHub Desktop.

Select an option

Save neochar/bd7319b597da818cddf043488ec23719 to your computer and use it in GitHub Desktop.
Upload data to Minio using CURL
#!/bin/bash
# Usage: ./minio-upload testbucket testfile.txt
bucket=$1
file=$2
host=127.0.0.1:9000
s3_key=testuser
s3_secret=testpassword
resource="/${bucket}/${file}"
content_type="application/octet-stream"
date=`date -R`
_signature="PUT\n\n${content_type}\n${date}\n${resource}"
signature=`echo -en ${_signature} | openssl sha1 -hmac ${s3_secret} -binary | base64`
curl -X PUT -T "${file}" \
-H "Host: ${host}" \
-H "Date: ${date}" \
-H "Content-Type: ${content_type}" \
-H "Authorization: AWS ${s3_key}:${signature}" \
https://${host}${resource}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment