aws python sdk批量上传_python – 使用POST的基于Amazon AWS S3浏览器的上传 –

我正在构建一个包含文件上载功能的Web应用程序.我的目标是从用户直接上传到S3存储桶.策略是预先签署将作为表单提交的POST请求.

包版是一个SignatureDoesNotMatch错误 – 据我所知,我已经符合文档,并且已经探索了很多选项,但仍然无法解决.我能够生成预先签名的下载链接.

引用:

生成签名请求:

def s3_upload_creds(name, user):

s3 = boto3.client('s3')

key = '${filename}'

region = 'us-east-1'

date_short = datetime.datetime.utcnow().strftime('%Y%m%d')

date_long = datetime.datetime.utcnow().strftime('%Y%m%dT000000Z')

fields = {

'acl': 'private',

'date': date_short,

'region': region,

'x-amz-algorithm': 'AWS4-HMAC-SHA256',

'x-amz-date': date_long

}

return s3.generate_presigned_post(

Bucket = 'leasy',

Fields = fields,

Key = key,

Conditions = [

{'acl': 'private'},

{'x-amz-algorithm': 'AWS4-HMAC-SHA256'},

{'x-amz-credential': '/'.join(['AKI--snip--', date_short, region, 's3', 'aws4_request'])},

{'x-amz-date': date_long}

]

)

上传表单(填充上面的字段):

{{ creds }}

Key to upload:

File:

相关部分的回复:

SignatureDoesNotMatch

The request signature we calculated does not match the signature you provided. Check your key and signing method.

AKI--snip--

eyJjb25kaXRpb25zIjogW3siYWNsIjogInByaXZhdGUifSwgeyJ4LWFtei1hbGdvcml0aG0iOiAiQVdTNC1ITUFDLVNIQTI1NiJ9LCB7IngtYW16LWNyZWRlbnRpYWwiOiAiQUtJQUlDVjRNVlBUUlFHU1lLV1EvMjAxNTEyMTgvdXMtZWFzdC0xL3MzL2F3czRfcmVxdWVzdCJ9LCB7IngtYW16LWRhdGUiOiAiMjAxNTEyMThUMDAwMDAwWiJ9LCB7ImJ1Y2tldCI6ICJsZWFzeSJ9LCBbInN0YXJ0cy13aXRoIiwgIiRrZXkiLCAiIl1dLCAiZXhwaXJhdGlvbiI6ICIyMDE1LTEyLTE4VDA1OjEwOjU2WiJ9

wDOjsBRc0iIW7JNtz/4GHgfvKaU=

StringToSign的Base64解码上面的错误:

{u'conditions': [{u'acl': u'private'},

{u'x-amz-algorithm': u'AWS4-HMAC-SHA256'},

{u'x-amz-credential': u'AKI--snip--/20151218/us-east-1/s3/aws4_request'},

{u'x-amz-date': u'20151218T000000Z'},

{u'bucket': u'leasy'},

[u'starts-with', u'$key', u'']],

u'expiration': u'2015-12-18T04:59:32Z'}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值