fix /issues/2592: web: Use Unicode paths to send files on Windows under Python 2

This commit is contained in:
robot3498712 2017-06-15 12:49:00 +02:00
parent d9c8f97318
commit bc8a8ecf5f

View file

@ -217,12 +217,13 @@ def all_items():
@app.route('/item/<int:item_id>/file')
def item_file(item_id):
item = g.lib.get_item(item_id)
item_path = util.syspath(item.path) if os.name == 'nt' else util.py3_path(item.path)
response = flask.send_file(
util.py3_path(item.path),
item_path,
as_attachment=True,
attachment_filename=os.path.basename(util.py3_path(item.path)),
)
response.headers['Content-Length'] = os.path.getsize(item.path)
response.headers['Content-Length'] = os.path.getsize(item_path)
return response