[英]Change the downloading file name in Flask
I have created a api which returns a tar file. When i try to download it in swagger it gets downloaded with some random garbage name like "application_octet-stream_generate_blob_https___editor.swagger.io_9ecd1754-0f85-4ed7-97ca-816bb446e5e2"
the file name should be migration.tar
This is my code
response = send_file(fpath, as_attachment=True, mimetype="application/octet-stream",download_name="migration.tar")
return response
When i try to download it in postman it works fine Thanks in advance..
您可以使用参数download_name
指定文件的名称。
return send_file( fpath, mimetype="application/octet-stream", as_attachment=True, download_name="migration.tar" )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.