Skip to content

Commit

Permalink
bug fixed for download non english name file (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
mars-martin-line authored Jan 21, 2021
1 parent bee03fc commit 119a986
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion common/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
6 changes: 3 additions & 3 deletions modules/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from lib.config import config
from lib.logger import logger
import base64
from urllib.parse import quote

log = logger(__name__)

Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion views/image.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<body>
{% include 'nav.html' %}
<div style="margin: 0 40px;">
<img src="{{ base64 }}" />
<img src="{{ base64 }}" style="max-width:1024px;" />
</div>
</body>

Expand Down

0 comments on commit 119a986

Please sign in to comment.