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 年前
相關內容
- 已提問 1 年前
- AWS 官方已更新 2 年前
- AWS 官方已更新 10 個月前
- AWS 官方已更新 2 年前