加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

如何生成文件链接没有到期?

发布时间:2020-12-16 21:48:52 所属栏目:Python 来源:网络整理
导读:在AWS S3中,如何为文件生成文件下载URL而不会过期. conn = boto.connect_s3(awsAccessKey,awsSecret)# Get bucket instance.bucket = conn.get_bucket(bktName)fileKey = bucket.get_key(fileKey)url = fileKey.generate_url(expires_in=None,query_auth=Tru

在AWS S3中,如何为文件生成文件下载URL而不会过期.

conn = boto.connect_s3(awsAccessKey,awsSecret)

# Get bucket instance.
bucket = conn.get_bucket(bktName)

fileKey = bucket.get_key(fileKey)
url = fileKey.generate_url(expires_in=None,query_auth=True,force_http=True)
print url

如何为文件生成url而没有到期?

最佳答案
根据最新文档(http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html):

A presigned URL can be valid for a maximum of seven days because the
signing key you use in signature calculation is valid for up to seven
days.

由于签名本身只能有效七天,因此签名URL无法生效超过七天.拥有永久有效URL的唯一方法是将文件设为公共.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读