1 回答
- 最新
- 投票最多
- 评论最多
0
【以下的回答经过翻译处理】 根据send_file()函数,我猜测你在使用Flask,如果文件很小,将文件存储在内存中(使用get_object())可能比下载到服务器文件系统中更容易。例如,类似于:
s3_result = s3.get_object(Bucket='bucket', Key='key')
response = make_response(s3_result['Body'].read())
response.headers['Content-Disposition'] = 'attachment; filename=myfile.txt'
response.mimetype = 'text/plain' # 或者你的文件的MIME类型
return response
如果文件很大,你可以将用户重定向到一个预签名的URL(可以使用boto3生成)。
相关内容
- AWS 官方已更新 2 年前
- AWS 官方已更新 4 个月前
- AWS 官方已更新 2 年前