Fix request mimetype for POST upload
This commit is contained in:
parent
3cbf858e6b
commit
670b183d04
11
app.py
11
app.py
|
@ -27,7 +27,7 @@ for location in config_locations:
|
|||
if app.config.from_file(os.path.expanduser(location + "pilpil-client.toml"), load=toml.load, silent=True):
|
||||
print(_("Found configuration file in {}").format(os.path.expanduser(location)))
|
||||
|
||||
upload_folder = os.path.expanduser(app.config['DEFAULT']['media_folder_local'])
|
||||
upload_folder = os.path.join(os.path.expanduser(app.config['DEFAULT']['media_folder_local']), "")
|
||||
media_exts = app.config['DEFAULT']['media_exts']
|
||||
HTTP_secret = str(app.config['DEFAULT']['auth'])
|
||||
debug = app.config['DEFAULT']['debug']
|
||||
|
@ -55,6 +55,7 @@ if debug:
|
|||
|
||||
upload_candidates = {}
|
||||
|
||||
|
||||
@auth.verify_password
|
||||
def verify_password(username, password):
|
||||
'''
|
||||
|
@ -163,8 +164,6 @@ def list_media_files(folder):
|
|||
# TODO : Return a dict list [{"filename":"foo", "size":-1}, {...}]
|
||||
fd_size = os.stat(folder + fd).st_size
|
||||
file_dict = {"filename": fd, "size": fd_size}
|
||||
if debug:
|
||||
print(str(file_dict))
|
||||
medias.append(file_dict)
|
||||
return medias
|
||||
else:
|
||||
|
@ -221,14 +220,15 @@ def upload_file(over_write=1):
|
|||
global upload_candidates
|
||||
media_files = list_media_files(upload_folder)
|
||||
if debug:
|
||||
print("Existing files : {}".format(str(list_media_files(upload_folder))))
|
||||
print("Upload candidates : {}".format(str(list_media_files(upload_folder))))
|
||||
if request.method == "GET":
|
||||
# Send candidates list
|
||||
if debug:
|
||||
print("GET :" + str(upload_candidates))
|
||||
return upload_candidates
|
||||
if request.method == "POST":
|
||||
if request.get_json():
|
||||
if request.is_json:
|
||||
print("HERE")
|
||||
# JSON received, parse it
|
||||
upload_candidates = request.get_json()
|
||||
# ~ upload_candidates = [candidate for candidate in upload_candidates if candidate not in media_files]
|
||||
|
@ -246,6 +246,7 @@ def upload_file(over_write=1):
|
|||
if debug:
|
||||
print("POST :" + str(upload_candidates))
|
||||
return upload_candidates
|
||||
else:
|
||||
# Check if the post request has the file part
|
||||
if "file" not in request.files:
|
||||
return _("No file part: {}").format(str(request.files))
|
||||
|
|
Loading…
Reference in New Issue