Minor fix to support "~/" like part in path parameter
This commit is contained in:
@@ -465,7 +465,7 @@ def get_directory_tree():
|
|||||||
def get_file():
|
def get_file():
|
||||||
# Retrieve filename from the POST request
|
# Retrieve filename from the POST request
|
||||||
if 'file_path' in request.form:
|
if 'file_path' in request.form:
|
||||||
file_path = request.form['file_path']
|
file_path = os.path.expanduser(request.form['file_path'])
|
||||||
else:
|
else:
|
||||||
return jsonify({"error": "file_path is required"}), 400
|
return jsonify({"error": "file_path is required"}), 400
|
||||||
|
|
||||||
@@ -481,7 +481,7 @@ def get_file():
|
|||||||
def upload_file():
|
def upload_file():
|
||||||
# Retrieve filename from the POST request
|
# Retrieve filename from the POST request
|
||||||
if 'file_path' in request.form and 'file_data' in request.files:
|
if 'file_path' in request.form and 'file_data' in request.files:
|
||||||
file_path = request.form['file_path']
|
file_path = os.path.expanduser(request.form['file_path'])
|
||||||
file = request.files["file_data"]
|
file = request.files["file_data"]
|
||||||
file.save(file_path)
|
file.save(file_path)
|
||||||
return "File Uploaded"
|
return "File Uploaded"
|
||||||
@@ -507,7 +507,7 @@ def change_wallpaper():
|
|||||||
if not path:
|
if not path:
|
||||||
return "Path not supplied!", 400
|
return "Path not supplied!", 400
|
||||||
|
|
||||||
path = Path(path)
|
path = Path(os.path.expanduser(path))
|
||||||
|
|
||||||
if not path.exists():
|
if not path.exists():
|
||||||
return f"File not found: {path}", 404
|
return f"File not found: {path}", 404
|
||||||
@@ -538,7 +538,7 @@ def download_file():
|
|||||||
if not url or not path:
|
if not url or not path:
|
||||||
return "Path or URL not supplied!", 400
|
return "Path or URL not supplied!", 400
|
||||||
|
|
||||||
path = Path(path)
|
path = Path(os.path.expanduser(path))
|
||||||
path.parent.mkdir(parents=True, exist_ok=True)
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
max_retries = 3
|
max_retries = 3
|
||||||
@@ -567,7 +567,7 @@ def open_file():
|
|||||||
if not path:
|
if not path:
|
||||||
return "Path not supplied!", 400
|
return "Path not supplied!", 400
|
||||||
|
|
||||||
path = Path(path)
|
path = Path(os.path.expanduser(path))
|
||||||
|
|
||||||
if not path.exists():
|
if not path.exists():
|
||||||
return f"File not found: {path}", 404
|
return f"File not found: {path}", 404
|
||||||
|
|||||||
Reference in New Issue
Block a user