【发布时间】:2017-04-14 00:45:18
【问题描述】:
这是我使用的链接 (Download files from Amazon S3 with Django)。使用它我可以下载单个文件。
代码:
s3_template_path = queryset.values('file')
filename = 'test.pdf'
conn = boto.connect_s3('<aws access key>', '<aws secret key>')
bucket = conn.get_bucket('your_bucket')
s3_file_path = bucket.get_key(s3_template_path)
response_headers = {
'response-content-type': 'application/force-download',
'response-content-disposition':'attachment;filename="%s"'% filename
}
url = s3_file_path.generate_url(60, 'GET',
response_headers=response_headers,
force_http=True)
return HttpResponseRedirect(url)
我需要从 S3 下载多个文件,因为 zip 会更好。是否可以修改和使用上述方法。如果不是,请建议其他方法。
【问题讨论】:
-
您要查找的每个文件的 s3_template_path 是否相同?
-
不,模板路径不同
标签: python django amazon-web-services amazon-s3