#3 add delete function
This commit is contained in:
@@ -32,7 +32,7 @@ class MinioService:
|
||||
if r.status_code == 200:
|
||||
print("Successfully uploaded a file!")
|
||||
else:
|
||||
print("Something went wrong")
|
||||
print("Something went wrong while creating")
|
||||
except:
|
||||
return False
|
||||
return True
|
||||
@@ -53,3 +53,21 @@ class MinioService:
|
||||
except:
|
||||
print("Error downloading file from minio")
|
||||
return file_bytes
|
||||
|
||||
@staticmethod
|
||||
def delete_file(filename: str) -> bool:
|
||||
"""Delete an file from the dropbox storage.
|
||||
|
||||
:param filename: filename of the file
|
||||
:return: Whether file was successfully deleted
|
||||
"""
|
||||
try:
|
||||
url = settings.AWS_HOST + filename
|
||||
r = requests.delete(url)
|
||||
if r.status_code == 204:
|
||||
print("Successfully deleted a file!")
|
||||
else:
|
||||
print("Something went wrong while deleting")
|
||||
except:
|
||||
return False
|
||||
return True
|
||||
Reference in New Issue
Block a user