1
0
mirror of https://github.com/LibreTranslate/LibreTranslate.git synced 2024-11-05 07:20:13 +01:00

change tmp dir

This commit is contained in:
Sébastien Thuret 2021-10-25 11:06:39 +02:00
parent 8d5a418bee
commit 5f2d0435f2
No known key found for this signature in database
GPG Key ID: 4742E2D66933BB08

View File

@ -19,6 +19,9 @@ from .api_keys import Database
from .suggestions import Database as SuggestionsDatabase
def get_upload_dir():
return os.path.join(tempfile.gettempdir(), "libretranslate-files-translate")
def get_json_dict(request):
d = request.get_json()
if not isinstance(d, dict):
@ -578,7 +581,7 @@ def create_app(args):
try:
filename = str(uuid.uuid4()) + '.' + secure_filename(file.filename)
filepath = os.path.join(tempfile.gettempdir(), filename)
filepath = os.path.join(get_upload_dir(), filename)
file.save(filepath)
@ -600,7 +603,7 @@ def create_app(args):
Download a translated file
"""
filename.split('.').pop(0)
filepath = os.path.join(tempfile.gettempdir(), filename)
filepath = os.path.join(get_upload_dir(), filename)
return_data = io.BytesIO()
with open(filepath, 'rb') as fo: