Add update endpoint for API
This commit is contained in:
parent
8371aba88b
commit
7c8e2a9f23
@ -179,12 +179,6 @@ class ImageEndpoint:
|
|||||||
return JsonResponse({'Result': 'Error - Could not find image to be updated',
|
return JsonResponse({'Result': 'Error - Could not find image to be updated',
|
||||||
'id': identifier}, status=404, safe=False)
|
'id': identifier}, status=404, safe=False)
|
||||||
|
|
||||||
for service in ImageEndpoint.storageServiceList:
|
|
||||||
service.delete_file(metadata['filename'])
|
|
||||||
|
|
||||||
MongoDBService.deleteSingle(identifier)
|
|
||||||
|
|
||||||
|
|
||||||
payload = json.loads(request.body)
|
payload = json.loads(request.body)
|
||||||
b64encoded_image = payload['image_data']
|
b64encoded_image = payload['image_data']
|
||||||
identifier = payload['id']
|
identifier = payload['id']
|
||||||
@ -193,10 +187,10 @@ class ImageEndpoint:
|
|||||||
|
|
||||||
decoded_image = WrapperService.unwrap_file(b64encoded_image)
|
decoded_image = WrapperService.unwrap_file(b64encoded_image)
|
||||||
|
|
||||||
MongoDBService.createSingle(metadata, identifier, decoded_image)
|
MongoDBService.updateSingle(identifier, decoded_image)
|
||||||
|
|
||||||
for service in ImageEndpoint.storageServiceList:
|
for service in ImageEndpoint.storageServiceList:
|
||||||
if not service.create_file(filename, decoded_image):
|
if not service.update_file(filename, decoded_image):
|
||||||
print("Could not save image to " + service.name)
|
print("Could not save image to " + service.name)
|
||||||
|
|
||||||
return JsonResponse({'id': identifier, 'filename': filename},
|
return JsonResponse({'id': identifier, 'filename': filename},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user