MinIO object storage upload using curl

#!/bin/bash

# Usage: ./minio-upload my-bucket my-file.zip

bucket=$1
file=$2

host=minio.example.com
s3_key=svc_example_user
s3_secret=svc_example_user_password

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}

Src:

Share

Send HTTP requests using cURL

 

Reading a URL via GET:
curl http://example.com/
Defining any HTTP method (like POST or PUT):
curl http://example.com/users/1 -XPUT
Sending data with a request:
curl http://example.com/users -d"first_name=Bruce&last_name=Wayne"
If you use -d and do not set an HTTP request method it automatically defaults to POST. Performing basic authentication:
curl http://user:password@example.com/users/1
All together now:
curl http://user:password@example.com/users/1 -XPUT -d"screen_name=batman"
Share