Merge pull request #1279 from micahflee/1277_download_attachment

Set content-disposition to attachment for /download
This commit is contained in:
Saptak Sengupta 2021-02-22 00:01:19 +05:30 committed by GitHub
commit 3b99716392
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -200,10 +200,10 @@ class ShareModeWeb(SendBaseModeWeb):
r.headers.set("Content-Encoding", "gzip")
r.headers.set("Content-Length", self.filesize)
filename_dict = {
'filename': unidecode(basename),
'filename*': "UTF-8''%s" % url_quote(basename)
"filename": unidecode(basename),
"filename*": "UTF-8''%s" % url_quote(basename),
}
r.headers.set("Content-Disposition", "inline", **filename_dict)
r.headers.set("Content-Disposition", "attachment", **filename_dict)
r = self.web.add_security_headers(r)
# guess content type
(content_type, _) = mimetypes.guess_type(basename, strict=False)