[英]How to access data from presigned url(s) on S3 using boto3
我对使用 AWS S3 还很陌生,我对如何从预先签名的 url 链接中提取数据有点迷茫。 所以目前,我获得了aws_access_key_id
、 aws_secret_access_key
和region_name
。 但是,我不知道如何提取预签名 url,因为我确实看到预签名 url 还具有AWS access key id
、 expiration time
、 .json
、 response-content-disposition
、 response-content-type
和Signature
。 我也不知道该放下什么作为我的Params
钥匙。
除此之外,当我运行代码(我提供了不正确的密钥)时,我收到了InvalidRequest The authorization mechanism you have provided is not supported
。
示例预签名 url 链接:
https://video_annotations.s3.amazonaws.com/folder1/annotations/sub-folder1/9162dn28sd78n.json?respone-content-disposition=attachment$6B%50filename%9D812jad9.json&respone-content-type=application%3Fjson&AWSAccessKeyID=different_aws_access_key_id&Signature=pAKSR97&Expires=1661271906
这是我目前的代码:
client = boto3.client(
's3',
aws_access_key_id = 'my_aws_access_key_id',
aws_secret_access_key = 'my_aws_secret_access_key',
region_name = 'my_region_name'
)
url = client.generate_presigned_url('get_object',
Params={
'Bucket':'video_annotations',
'Key':'???',
},
ExpiresIn=1661271906)
print(url)
任何帮助将不胜感激。
关键只是桶中对象的路径,对于https://video_annotations.s3.amazonaws.com/folder1/annotations/sub-folder1/9162dn28sd78n.json?respone-content-disposition=attachment$6B%50filename%9D812jad9.json&respone-content-type=application%3Fjson&AWSAccessKeyID=different_aws_access_key_id&Signature=pAKSR97&Expires=1661271906
,密钥是folder1/annotations/sub-folder1/9162dn28sd78n.json
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.