mirror of
https://github.com/clearml/clearml-server
synced 2025-02-07 13:33:42 +00:00
Fix file server GET
response for gzipped data-files contains Content-Encoding: gz
header, causing clients to automatically decompress the file
This commit is contained in:
parent
083fd315e9
commit
6b480d7e87
@ -1,5 +1,6 @@
|
|||||||
""" A Simple file server for uploading and downloading files """
|
""" A Simple file server for uploading and downloading files """
|
||||||
import json
|
import json
|
||||||
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -48,8 +49,12 @@ def upload():
|
|||||||
@app.route("/<path:path>", methods=["GET"])
|
@app.route("/<path:path>", methods=["GET"])
|
||||||
def download(path):
|
def download(path):
|
||||||
as_attachment = "download" in request.args
|
as_attachment = "download" in request.args
|
||||||
|
|
||||||
|
_, encoding = mimetypes.guess_type(os.path.basename(path))
|
||||||
|
mimetype = "application/octet-stream" if encoding == "gzip" else None
|
||||||
|
|
||||||
response = send_from_directory(
|
response = send_from_directory(
|
||||||
app.config["UPLOAD_FOLDER"], path, as_attachment=as_attachment
|
app.config["UPLOAD_FOLDER"], path, as_attachment=as_attachment, mimetype=mimetype
|
||||||
)
|
)
|
||||||
if config.get("fileserver.download.disable_browser_caching", False):
|
if config.get("fileserver.download.disable_browser_caching", False):
|
||||||
headers = response.headers
|
headers = response.headers
|
||||||
|
Loading…
Reference in New Issue
Block a user