Python S3 Boto 生成带有 SignatureDoesNotMatch 错误的 URL

标签 python amazon-s3 boto

        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)

这将输出文件名和 URL 的列表。 当我关注某个 url 时,我会得到以下 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>

卡在这里,非常感谢任何帮助。

最佳答案

结果我的文件名包含波浪号 (~)。

这会弄乱 URL,从而导致错误。

关于Python S3 Boto 生成带有 SignatureDoesNotMatch 错误的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22975514/

相关文章:

java - Amazon S3 上传文件并获取 URL

amazon-web-services - 通过标签键过滤卷后,是否可以获取boto中的标签值?

amazon-web-services - 如何跟踪异步 AWS Lambda 调用的进度/状态?

python - torch.autograd.Variable 的目的是什么?

python - 将具有相似(但略有不同)子字符串的字符串重新映射到相同的结果

python - 通过 Pandas 中的函数替换 NaN 时索引超出范围

google-chrome - 使用 MapBox loadImage 函数时,仅在 Chrome 中出现 AWS S3 CORS 错误

django - 您如何配置 S3BotoStorage 或 collectstatic 以上传到 s3 存储桶子目录

python - Boto connect_xxx 方法和连接池

python - 重用生成器表达式