如何在没有过期的情况下生成文件链接?

Hit*_*try 5 python amazon-s3 amazon-ec2 boto amazon-web-services

在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
Run Code Online (Sandbox Code Playgroud)

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

Jas*_*rth 5

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

预签名URL最多可以有效七天,因为您在签名计算中使用的签名密钥有效期最长为七天.

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


dat*_*age -1

链接过期是为了在不暴露身份验证密钥的情况下允许对私有文件进行有限的访问。

如果您想让某个文件始终可用,请将该文件公开,或者向其他 s3 用户提供权限。