如何使用带有S3协议的curl来上传对象swift openstack?

时间:2019-06-25 07:07:24

标签: amazon-s3

我想使用带有curl的s3协议将文件上传到Swift Openstack

#!/bin/bash
file=README.md
bucket=bucket
resource="/${bucket}/${file}"
contentType="application/x-compressed-tar"
dateValue=`date -R`
stringToSign="PUT\n\n${contentType}\n${dateValue}\n${resource}"
s3Key=xxxxxxxxxxxxxxxxx
s3Secret=xxxxxxxxxxxxxxxxxxxx
signature=`echo -en ${stringToSign} | openssl sha1 -hmac ${s3Secret} -binary | base64`
curl -X PUT -T "${file}" \
  -H "Host: https://xxxxx.com" \
  -H "Date: ${dateValue}" \
  -H "Content-Type: ${contentType}" \
  -H "Authorization: AWS ${s3Key}:${signature}" \
  https://xxxxx.com/${bucket}/${file}

我的脚本出了什么问题? 总是响应404错误

1 个答案:

答案 0 :(得分:0)

我认为失败了,因为您尝试访问的URI是受保护的URL,并且在发出此请求之前还需要传递身份验证令牌。