Fix bug where filename is used instead of identifier
This commit is contained in:
parent
7c8e2a9f23
commit
36226186a0
@ -54,15 +54,17 @@ class MinioService(StorageServiceInterface):
|
|||||||
:param file: Byte representation of the file to save as new version
|
:param file: Byte representation of the file to save as new version
|
||||||
:return True if successful, False otherwise
|
:return True if successful, False otherwise
|
||||||
"""
|
"""
|
||||||
|
identifier = filename.strip('.jpg')
|
||||||
|
print("Trying to update image with identifier ", identifier)
|
||||||
try:
|
try:
|
||||||
headers = {'Content-Type': 'binary/octet-stream'}
|
headers = {'Content-Type': 'binary/octet-stream'}
|
||||||
i = 0
|
i = 0
|
||||||
while MinioService.read_file(filename + '_' + str(i)) is not False:
|
while MinioService.read_file(identifier + '_' + str(i) + '.jpg') is not False:
|
||||||
i = i + 1
|
i = i + 1
|
||||||
url = settings.AWS_HOST + filename + '_' + str(i)
|
url = settings.AWS_HOST + identifier + '_' + str(i) + '.jpg'
|
||||||
r = requests.put(url, data=file, headers=headers)
|
r = requests.put(url, data=file, headers=headers)
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
print("Successfully uploaded a new version with identifier %s!".format(filename + '_' + str(i)))
|
print("Successfully uploaded a new version with filename %s!".format(identifier + '_' + str(i) + '.jpg'))
|
||||||
else:
|
else:
|
||||||
print("Something went wrong while updating")
|
print("Something went wrong while updating")
|
||||||
except:
|
except:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user