How to set the file name in response

I know about the content, but I read what it uses for email messages. And I want to know how I can set the file name with the content type. ps i am using pyramid framework

edit: There is a download button on the website how to execute a Response object for a file name, for example

return Response(body=f.read(), content_type='application/octet-stream')

and what I need to do to display the correct file name in the browser.

+5
source share
1 answer

You need to set the Content-Disposition header file name parameter as follows:

response.content_disposition = 'attachment; filename="my_filename.txt"'
+16
source

All Articles