我正在尝试为 S3 文件夹(它本身包含更多文件夹/文件)生成一个预先签名的 url,并将其分发给我的客户,以便他们可以下载其内容。即通过单击链接,用户将文件夹下载到他们的本地磁盘。
但是,我在 XML 对话中不断收到“没有这样的键”错误。
我正在使用来自 boto3 sdk 的 client.generate_presigned_url()
def create_presigned_url(bucket, object):
try:
url = s3_client.generate_presigned_url(
'get_object',
Params={
'Bucket': bucket,
'Key': object
},
ExpiresIn=240,
HttpMethod='GET'
)
except ClientError as e:
print(e)
return None
return url
Run Code Online (Sandbox Code Playgroud)
这是错误消息:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Key>output/BARNES/070419/APR19BAR/</Key>
<RequestId>E6BE736FE945FA22</RequestId>
<HostId>
hk3+d+***********************************************************+EO2CZmo=
</HostId>
</Error>
Run Code Online (Sandbox Code Playgroud)