import boto
from boto.s3.connection import S3Connection
import requests
conn = S3Connection('-----------------', '-------------------')
snapsbucket = conn.get_bucket('snaps-snaps')
for key in snapsbucket.list('a'):
print key.name
print key.generate_url(expires_in=90)
这将输出文件名和网址列表。 当我关注网址时,我得到以下xml:
<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>
The request signature we calculated does not match the signature you provided. Check your key and signing method.
</Message>
<StringToSignBytes>
47 45 54 0a 0a 0a 31 33 39 37 30 38 34 30 35 37 0a 2f 73 6e 61 70 73 2d 73 6e 61 70 73 2f 61 73 73 65 6c 69 6e 70 61 75 6c 5f 61 73 73 65 6c 69 6e 70 61 75 6c 7e 31 33 39 36 39 38 36 38 37 39 34 36 35 2e 6d 70 34
</StringToSignBytes>
<RequestId>2C2A6E1194BAAD85</RequestId>
<HostId>
ReNCy1k3OqBd2xyfA5tyixhD7MXnNACqBspsl61IAN7GSF1haK03cv4r6x6WHle/
</HostId>
<SignatureProvided>IlRoL9AZJZQYL4/L0wySexMBjnw=</SignatureProvided>
<StringToSign>
GET 1397084057 /snaps-snaps/asselinpaul_asselinpaul~1396986879465.mp4
</StringToSign>
<AWSAccessKeyId>--------------</AWSAccessKeyId>
</Error>
坚持到这里,任何帮助都非常感激。
答案 0 :(得分:1)
事实证明我的文件名包含代字号(〜)。
这会弄乱网址,从而导致错误。