[英]boto3 s3 generate_presigned_url ExpiresIn doesn't work as expected
I have tried to generate pre-signed URL
with 7dsys expiration time.我试图生成具有 7dsys 到期时间
pre-signed URL
。 (It is saying maximum duration is 7days, AWS S3 pre signed URL without Expiry date ) (也就是说最长持续时间是 7 天, AWS S3 预签名 URL 没有到期日期)
# It is called and retruned in AWS Lambda
boto3.client('s3').generate_presigned_url(
'get_object',
Params={'Bucket': bucket, 'Key': object_key},
ExpiresIn=(60*60*24*7) # 7days
)
However, it seems not to retain the pre-signed URL
for 7days but just several hours.但是,它似乎不会将
pre-signed URL
保留 7 天,而只是几个小时。 The pre-signed URL
just returns the XML format after that. pre-signed URL
之后只返回 XML 格式。
<Error>
<Code>ExpiredToken</Code>
<Message>The provided token has expired.</Message>
.
.
.
</Error>
It seems even to be different expiration time every time I try, sometimes 5 hours, sometime 12hours.每次尝试的过期时间似乎都不同,有时是 5 小时,有时是 12 小时。
I don't know why.我不知道为什么。
import boto3
from botocore.client
import Config
# Get the service client with sigv4 configured
s3 = boto3.client('s3', config=Config(signature_version='s3v4'))
# Generate the URL to get 'key-name' from 'bucket-name'
# URL expires in 604800 seconds (seven days)
url = s3.generate_presigned_url(ClientMethod='get_object',Params={
'Bucket':'bucket-name',
'Key': 'key-name'
},ExpiresIn=604800)
print(url)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.