Fix bug where old image was not saved on AWS
This commit is contained in:
parent
6f7936cc4b
commit
d500518d8f
@ -70,7 +70,7 @@ class DropboxService(StorageServiceInterface):
|
||||
return file_bytes
|
||||
|
||||
@staticmethod
|
||||
def move_file(identifier_from: str, identifier_to: str, file: bytes = None) -> bool:
|
||||
def move_file(identifier_from: str, identifier_to: str) -> bool:
|
||||
"""Move/Rename a file on the dropbox storage.
|
||||
|
||||
:param identifier_from: Location of the file to be moved
|
||||
|
||||
@ -66,7 +66,7 @@ class MinioService(StorageServiceInterface):
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def move_file(identifier_from: str, identifier_to: str, file: bytes) -> bool:
|
||||
def move_file(identifier_from: str, identifier_to: str) -> bool:
|
||||
"""Move/Rename a file on the S3 storage.
|
||||
|
||||
Consists of a PUT method (copying the object) and a delete method.
|
||||
@ -79,6 +79,8 @@ class MinioService(StorageServiceInterface):
|
||||
filename_from = identifier_from + '.jpg'
|
||||
filename_to = identifier_to
|
||||
|
||||
file = MinioService.read_file(filename_from)
|
||||
|
||||
if not MinioService.delete_file(filename_from):
|
||||
print("MinioService: Updating (delete) file {} failed".format(filename_from))
|
||||
return False
|
||||
|
||||
@ -238,12 +238,9 @@ class ImageEndpoint:
|
||||
|
||||
MongoDBService.updateSingle(identifier, decoded_image, metadata)
|
||||
|
||||
# TODO TOBIAS get old image for MinIO
|
||||
old_bytes = None
|
||||
|
||||
for service in ImageEndpoint.storageServiceList:
|
||||
orig_new_name = identifier + '_' + str(metadata['version']) + '.jpg'
|
||||
if not service.move_file(identifier, orig_new_name, old_bytes):
|
||||
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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user