Check if image with same name already exists
This commit is contained in:
parent
46420eecda
commit
f100732e4d
@ -73,6 +73,9 @@ def upload():
|
|||||||
|
|
||||||
if f: # if the uploaded image exists
|
if f: # if the uploaded image exists
|
||||||
print("Uploaded image exists")
|
print("Uploaded image exists")
|
||||||
|
if Path(os.path.join(settings.UPLOAD_FOLDER, fname)).is_file():
|
||||||
|
print("Requested filename already exists!")
|
||||||
|
return jsonify({'status': 'error', 'error': 'FILENAME_TAKEN'}), status.HTTP_409_CONFLICT
|
||||||
f.save(os.path.join(settings.UPLOAD_FOLDER, fname)) # save the image
|
f.save(os.path.join(settings.UPLOAD_FOLDER, fname)) # save the image
|
||||||
print("Saved to {0}".format(fname))
|
print("Saved to {0}".format(fname))
|
||||||
url = settings.ROOTURL + fname # construct the url to the image
|
url = settings.ROOTURL + fname # construct the url to the image
|
||||||
|
Reference in New Issue
Block a user