以附件形式发送文件
Sending file as an attachment
我尝试使用以下方式向用户 iam 发送文件:
return static_file( filename, root='/home/nikos/public_html/static/files' )
但是当涉及到 .pdf 文件时,它会将它们打开到浏览器,而不仅仅是发送文件和所有其他文件,如 .docx,它发送的文件名只是 'file',而不是原始文件的文件名文件名。
如何将文件作为附件正确发送?
作为 mentioned in the docs 你可以简单地传递一个 download=True
参数,应该就是这样。
例如
return static_file(filename, root='/static/files', download=True)
您还可以为下载建议一个不同的文件名并传递它而不是 True
,例如download="Custom "+filename
我尝试使用以下方式向用户 iam 发送文件:
return static_file( filename, root='/home/nikos/public_html/static/files' )
但是当涉及到 .pdf 文件时,它会将它们打开到浏览器,而不仅仅是发送文件和所有其他文件,如 .docx,它发送的文件名只是 'file',而不是原始文件的文件名文件名。
如何将文件作为附件正确发送?
作为 mentioned in the docs 你可以简单地传递一个 download=True
参数,应该就是这样。
例如
return static_file(filename, root='/static/files', download=True)
您还可以为下载建议一个不同的文件名并传递它而不是 True
,例如download="Custom "+filename