1 回答
- 最新
- 投票最多
- 评论最多
2
Based on the send_file() function, am I right that you're using Flask? If the files are small, it might be easier to just keep the file in memory (using get_object()) rather than downloading it to the server's filesystem. For example, something like:
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' # or whatever the MIME type is of your file return response
If the files are large, you could instead redirect the user to a presigned url (which you can generate using boto3).
已回答 2 年前
相关内容
- AWS 官方已更新 2 年前
- AWS 官方已更新 3 年前
- AWS 官方已更新 1 年前
- AWS 官方已更新 2 年前