Rewrite update function consisting of move + create
This commit is contained in:
parent
e50e027ea9
commit
8c64333e27
@ -170,7 +170,6 @@ class ImageEndpoint:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
@api_view(['PUT'])
|
@api_view(['PUT'])
|
||||||
def image_api_update(request, identifier):
|
def image_api_update(request, identifier):
|
||||||
|
|
||||||
logger.debug('Image UPDATE single call: {}'.format(request))
|
logger.debug('Image UPDATE single call: {}'.format(request))
|
||||||
|
|
||||||
# get metadata from MongoDB
|
# get metadata from MongoDB
|
||||||
@ -190,8 +189,11 @@ class ImageEndpoint:
|
|||||||
MongoDBService.updateSingle(identifier, decoded_image)
|
MongoDBService.updateSingle(identifier, decoded_image)
|
||||||
|
|
||||||
for service in ImageEndpoint.storageServiceList:
|
for service in ImageEndpoint.storageServiceList:
|
||||||
if not service.update_file(filename, decoded_image):
|
orig_new_name = identifier + '_' + payload['metadata']['version'] + '.jpg'
|
||||||
print("Could not save image to " + service.name)
|
if not service.move_file(identifier, orig_new_name):
|
||||||
|
print("Could not move file from {} to {}".format(identifier, orig_new_name))
|
||||||
|
if not service.create_file(filename, decoded_image):
|
||||||
|
print("Could not save updated image to " + service.name)
|
||||||
|
|
||||||
return JsonResponse({'id': identifier, 'filename': filename},
|
return JsonResponse({'id': identifier, 'filename': filename},
|
||||||
safe=False)
|
safe=False)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user