How to upload S3 files with bash
Today, I will talk to you about how to upload S3 files with bash. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.
#! / bin/bashACCESS_KEY= "" SECRET_KEY= "" HOST= "s3.demo.com" BUCKET= "demo" CONTENT_TYPE= "application/octet-stream" FILENAME=/tmp/demoACL= "x-amz-acl:public-read" META_DATA= "x-amz-meta-ukey:value" FILESIZE=$ (stat-c% s "$FILENAME") FILEMD5= `cat ${FILENAME} | openssl dgst-md5-binary | openssl enc-Base64`Auth _ PATH= "/ ${BUCKET} ${FILENAME}" CURRENT_TIME= `TZ = GMT LANG=en_US date "+% a % d% b% Y% H:%M:%S GMT "`stringToSign=" PUT\ n$ {CONTENT_TYPE}\ n$ {CURRENT_TIME}\ n$ {ACL}\ n$ {META_DATA}\ n$ {AUTH_PATH} "signature= `echo-en ${stringToSign} | openssl sha1-hmac ${SECRET_KEY}-binary | Base64`curl-s-v-X PUT" http://${HOST}${AUTH_PATH}"\-H "Authorization: AWS ${ACCESS_KEY}: ${signature} "\-H" Date: ${CURRENT_TIME} "\-H" Host: ${HOST} "\-H" Content-Length: ${FILESIZE} "\-H" Content-MD5: ${FILEMD5} "\-H" Content-Type: ${CONTENT_TYPE} "\-H" {ACL} "\-H" ${META_DATA} "\-T" ${FILENAME} "read the above Do you have any further understanding of how bash implements S3 file upload? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.