forked from mirrors/LibreTranslate
change tmp dir
This commit is contained in:
parent
8d5a418bee
commit
5f2d0435f2
1 changed files with 5 additions and 2 deletions
|
@ -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):
|
||||||
|
|
||||||
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):
|
||||||
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:
|
||||||
|
|
Loading…
Reference in a new issue