匿名用户上传
bash
#!/bin/bash
bucket=mybucket
file=/home/database.yml
host=192.168.24.9:9000
resource="/${bucket}/${file}"
content_type="application/octet-stream"
date=`date -R`
echo $resource
echo "http://$host${resource}"
curl -v -X PUT -T "${file}" \
-H "Host: $host" \
-H "Date: ${date}" \
-H "Content-Type: ${content_type}" \
http://$host${resource}
使用账号密码上传
bash
#!/bin/bash
ACCESS_KEY="minioadmin"
SECRET_KEY="minioadmin"
BUCKET_NAME="mybucket"
FILE_NAME="/home/database.yml"
OBJECT_NAME="database.yml"
MINIO_URL="192.168.24.9:9000"
# 生成日期和签名
DATE_VALUE="$(date -R)"
SIGNATURE="$(echo -en "PUT\n\n\n${DATE_VALUE}\n/${BUCKET_NAME}/${OBJECT_NAME}" | openssl sha1 -hmac "${SECRET_KEY}" -binary | base64)"
curl -i -X PUT --upload-file "${FILE_NAME}" \
--header "Date: ${DATE_VALUE}" \
--header "Authorization: AWS ${ACCESS_KEY}:${SIGNATURE}" \
"${MINIO_URL}/${BUCKET_NAME}/${OBJECT_NAME}"