Compare commits
No commits in common. "b35e4030ace54edd81a555f910163cda983efb9c" and "191b54f113f8884ac40281ddc7e3545b436e54a7" have entirely different histories.
b35e4030ac
...
191b54f113
22
app.py
22
app.py
@ -466,30 +466,18 @@ def serve_file(subpath):
|
|||||||
filesize = os.path.getsize(file_path)
|
filesize = os.path.getsize(file_path)
|
||||||
|
|
||||||
# Figure out download flag and filename
|
# Figure out download flag and filename
|
||||||
as_attachment = request.args.get('download') == 'true'
|
ask_download = request.args.get('download') == 'true'
|
||||||
filename = os.path.basename(full_path)
|
filename = os.path.basename(full_path)
|
||||||
|
|
||||||
if as_attachment:
|
|
||||||
download_name = filename
|
|
||||||
mimetype = 'application/octet-stream'
|
|
||||||
else:
|
|
||||||
download_name = None
|
|
||||||
mimetype = mime
|
|
||||||
|
|
||||||
|
|
||||||
# Single send_file call with proper attachment handling
|
# Single send_file call with proper attachment handling
|
||||||
response = send_file(
|
response = send_file(
|
||||||
file_path,
|
file_path,
|
||||||
mimetype=mimetype,
|
mimetype=mime,
|
||||||
conditional=True,
|
conditional=True,
|
||||||
as_attachment=as_attachment ,
|
as_attachment=ask_download,
|
||||||
download_name=download_name
|
download_name=filename if ask_download else None
|
||||||
)
|
)
|
||||||
|
if not ask_download:
|
||||||
if as_attachment:
|
|
||||||
response.headers['X-Content-Type-Options'] = 'nosniff'
|
|
||||||
|
|
||||||
if not as_attachment :
|
|
||||||
response.headers['Content-Disposition'] = 'inline'
|
response.headers['Content-Disposition'] = 'inline'
|
||||||
response.headers['Cache-Control'] = 'public, max-age=86400'
|
response.headers['Cache-Control'] = 'public, max-age=86400'
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user