#3 add delete function

This commit is contained in:
Martin Weick
2020-12-07 10:15:07 +01:00
parent 2e3e9f9fad
commit 8a50493b18
2 changed files with 25 additions and 1 deletions
+19 -1
View File
@@ -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