1

in my attempt to send a file to the user iam using the following:

return static_file( filename, root='/home/nikos/public_html/static/files' )

But when it comes to .pdf files it opens them to the browser instead of just sendign the file and all other files like .docx it sends them with the filename being just 'file' and not with original file's filename.

How can i send the files properly as attachments?

1 Answers1

2

As mentioned in the docs you can simply pass a download=True argument and that should be it.

e.g.

return static_file(filename, root='/static/files', download=True)

You can also suggest a different filename for the download and pass that instead of True, e.g. download="Custom "+filename

shad0w_wa1k3r
  • 12,955
  • 8
  • 67
  • 90