Fix Download Bug.

This commit is contained in:
林檎 2017-03-29 12:59:20 +08:00
parent cbc807f3ff
commit ebb3acecca

View file

@ -40,7 +40,6 @@ from functools import wraps
import base64 import base64
from sqlalchemy.sql import * from sqlalchemy.sql import *
import json import json
import urllib
import datetime import datetime
from iso639 import languages as isoLanguages from iso639 import languages as isoLanguages
from iso639 import __version__ as iso639Version from iso639 import __version__ as iso639Version
@ -836,7 +835,7 @@ def get_opds_download_link(book_id, format):
else: else:
# file_name = helper.get_valid_filename(file_name) # file_name = helper.get_valid_filename(file_name)
response = make_response(send_from_directory(os.path.join(config.config_calibre_dir, book.path), data.name + "." + format)) response = make_response(send_from_directory(os.path.join(config.config_calibre_dir, book.path), data.name + "." + format))
response.headers=headers response.headers["Content-Disposition"] = "attachment; filename*=UTF-8''%s.%s" % (quote(file_name.encode('utf8')), format)
return response return response
@ -1645,13 +1644,13 @@ def get_download_link(book_id, format):
headers["Content-Type"] = mimetypes.types_map['.' + format] headers["Content-Type"] = mimetypes.types_map['.' + format]
except: except:
pass pass
headers["Content-Disposition"] = "attachment; filename*=UTF-8''%s.%s" % (urllib.quote(file_name.encode('utf-8')), format) headers["Content-Disposition"] = "attachment; filename*=UTF-8''%s.%s" % (quote(file_name.encode('utf-8')), format)
if config.config_use_google_drive: if config.config_use_google_drive:
df=gdriveutils.getFileFromEbooksFolder(Gdrive.Instance().drive, book.path, '%s.%s' % (data.name, format)) df=gdriveutils.getFileFromEbooksFolder(Gdrive.Instance().drive, book.path, '%s.%s' % (data.name, format))
return do_gdrive_download(df, headers) return do_gdrive_download(df, headers)
else: else:
response = make_response(send_from_directory(os.path.join(config.config_calibre_dir, book.path), data.name + "." + format)) response = make_response(send_from_directory(os.path.join(config.config_calibre_dir, book.path), data.name + "." + format))
response.headers=headers response.headers["Content-Disposition"] = "attachment; filename*=UTF-8''%s.%s" % (quote(file_name.encode('utf-8')), format)
return response return response
else: else:
abort(404) abort(404)