diff --git a/common/const.py b/common/const.py index c2deb4b..409f402 100644 --- a/common/const.py +++ b/common/const.py @@ -53,4 +53,4 @@ def __setattr__(self, name, value): const.ETAG_HEADER = "Etag" const.LAST_MODIFIED_HEADER = "Last-Modified" const.CONTENT_DISPOSITION_HEADER = "Content-Disposition" -const.ATTACHMENT_HEADER = "attachment; filename" +const.ATTACHMENT_HEADER = "attachment; filename={0}; filename*=utf-8''{0}" diff --git a/modules/core/api.py b/modules/core/api.py index 9d56afa..91edb9b 100644 --- a/modules/core/api.py +++ b/modules/core/api.py @@ -26,6 +26,7 @@ from lib.config import config from lib.logger import logger import base64 +from urllib.parse import quote log = logger(__name__) @@ -125,12 +126,11 @@ def download(id, prefix): file_info["status"], ) parts = prefix.split("/") + file_name = quote(parts[len(parts) - 1]) return Response( stream_with_context(file_info["stream"]), headers={ - const.CONTENT_DISPOSITION_HEADER: "{}={}".format( - const.ATTACHMENT_HEADER, parts[len(parts) - 1] - ) + const.CONTENT_DISPOSITION_HEADER: const.ATTACHMENT_HEADER.format(file_name) }, ) except Exception as e: diff --git a/views/image.html b/views/image.html index ed085bb..0cb654c 100644 --- a/views/image.html +++ b/views/image.html @@ -8,7 +8,7 @@ {% include 'nav.html' %}
- +