Skip to content

Commit

Permalink
fix beetbox/issues/2592: web: Use Unicode paths to send files on Wind…
Browse files Browse the repository at this point in the history
…ows under Python 2
  • Loading branch information
robot3498712 committed Jun 15, 2017
1 parent d9c8f97 commit bc8a8ec
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions beetsplug/web/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit bc8a8ec

Please sign in to comment.