added return and failsafe
This commit is contained in:
parent
47dfe26ace
commit
d093dbb5b9
@ -63,6 +63,9 @@ class MongoDBService:
|
|||||||
|
|
||||||
except:
|
except:
|
||||||
print("Could not insert Metadata")
|
print("Could not insert Metadata")
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def deleteSingle(identifier):
|
def deleteSingle(identifier):
|
||||||
|
|||||||
@ -60,7 +60,7 @@ class ImageEndpoint:
|
|||||||
logger.debug('Actual Dropbox SHA512: {}'.format(actual_dropbox_hash))
|
logger.debug('Actual Dropbox SHA512: {}'.format(actual_dropbox_hash))
|
||||||
if stored_hash != actual_dropbox_hash:
|
if stored_hash != actual_dropbox_hash:
|
||||||
return JsonResponse('Stored hash does not match generated one! '
|
return JsonResponse('Stored hash does not match generated one! '
|
||||||
'stored: {} actual: {}'.format(stored_hash, actual_dropbox_hash), safe=False)
|
'stored: {} actual: {}'.format(stored_hash, actual_dropbox_hash), status=400, safe=False)
|
||||||
|
|
||||||
# get image bytes from MinIO
|
# get image bytes from MinIO
|
||||||
minio_image_bytes = MinioService.read_file(metadata['filename'])
|
minio_image_bytes = MinioService.read_file(metadata['filename'])
|
||||||
@ -73,7 +73,7 @@ class ImageEndpoint:
|
|||||||
logger.debug('Actual MinIO SHA512: {}'.format(actual_minio_hash))
|
logger.debug('Actual MinIO SHA512: {}'.format(actual_minio_hash))
|
||||||
if stored_hash != actual_minio_hash:
|
if stored_hash != actual_minio_hash:
|
||||||
return JsonResponse('Stored hash does not match generated one! '
|
return JsonResponse('Stored hash does not match generated one! '
|
||||||
'stored: {} actual: {}'.format(stored_hash, actual_minio_hash), status=404, safe=False)
|
'stored: {} actual: {}'.format(stored_hash, actual_minio_hash), status=400, safe=False)
|
||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
'id': identifier,
|
'id': identifier,
|
||||||
@ -95,14 +95,17 @@ class ImageEndpoint:
|
|||||||
|
|
||||||
decoded_image = WrapperService.unwrap_file(b64encoded_image)
|
decoded_image = WrapperService.unwrap_file(b64encoded_image)
|
||||||
|
|
||||||
MongoDBService.createSingle(metadata, identifier, decoded_image)
|
if not MongoDBService.createSingle(metadata, identifier, decoded_image):
|
||||||
|
print("Could not save metadata")
|
||||||
|
return JsonResponse({'Result': 'Error - could not upload to MongoDB', 'id': identifier, 'filename': filename}, status=500,safe=False)
|
||||||
if not DropboxService.create_file(filename, decoded_image):
|
if not DropboxService.create_file(filename, decoded_image):
|
||||||
print("Could not save image to dropbox")
|
print("Could not save image to dropbox")
|
||||||
|
return JsonResponse({'Result': 'Error - could not upload to Dropbox', 'id': identifier, 'filename': filename},status=500, safe=False)
|
||||||
if not MinioService.create_file(filename, decoded_image):
|
if not MinioService.create_file(filename, decoded_image):
|
||||||
print("Could not save image to minio")
|
print("Could not save image to minio")
|
||||||
return JsonResponse({'id': identifier, 'filename': filename},
|
return JsonResponse({'Result': 'Error - could not upload to MinIO', 'id': identifier, 'filename': filename}, status=500, safe=False)
|
||||||
safe=False) # 'metadata': metadata response beinhaltet ObjectId welche nicht serializable is?
|
|
||||||
|
return JsonResponse({'id': identifier, 'filename': filename},safe=False)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@api_view(['DELETE'])
|
@api_view(['DELETE'])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user