Skip to content
Snippets Groups Projects
Unverified Commit 5f2d0435 authored by Sébastien Thuret's avatar Sébastien Thuret
Browse files

change tmp dir

parent 8d5a418b
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,9 @@ from .api_keys import Database ...@@ -19,6 +19,9 @@ from .api_keys import Database
from .suggestions import Database as SuggestionsDatabase from .suggestions import Database as SuggestionsDatabase
def get_upload_dir():
return os.path.join(tempfile.gettempdir(), "libretranslate-files-translate")
def get_json_dict(request): def get_json_dict(request):
d = request.get_json() d = request.get_json()
if not isinstance(d, dict): if not isinstance(d, dict):
...@@ -578,7 +581,7 @@ def create_app(args): ...@@ -578,7 +581,7 @@ def create_app(args):
try: try:
filename = str(uuid.uuid4()) + '.' + secure_filename(file.filename) 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) file.save(filepath)
...@@ -600,7 +603,7 @@ def create_app(args): ...@@ -600,7 +603,7 @@ def create_app(args):
Download a translated file Download a translated file
""" """
filename.split('.').pop(0) filename.split('.').pop(0)
filepath = os.path.join(tempfile.gettempdir(), filename) filepath = os.path.join(get_upload_dir(), filename)
return_data = io.BytesIO() return_data = io.BytesIO()
with open(filepath, 'rb') as fo: with open(filepath, 'rb') as fo:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment