我知道内容处理,但我读了它用于电子邮件的内容。我想知道如何使用content-type设置文件名。 ps我使用Pyramid框架
编辑: 网站有按钮'下载'如何执行文件名的响应对象,如
return Response(body=f.read(), content_type='application/octet-stream')
以及我在浏览器中显示正确文件名所需要做的事情。
答案 0 :(得分:17)
您需要设置Content-Disposition标头的filename参数,如下所示:
response.content_disposition = 'attachment; filename="my_filename.txt"'