Add update function for Dropbox

This commit is contained in:
Tobias Eidelpes 2021-01-07 18:00:50 +01:00
parent b98976a016
commit 79985f1139

View File

@ -6,7 +6,6 @@ from app_be.services.StorageServiceInterface import StorageServiceInterface
class DropboxService(StorageServiceInterface):
name = "Dropbox"
@staticmethod
@ -57,13 +56,24 @@ class DropboxService(StorageServiceInterface):
@staticmethod
def update_file(filename: str, file: bytes) -> bool:
"""Update (currently: overwrite) an file on the dropbox storage.
"""Update a file on the dropbox storage.
Increments a counter until we get to the newest version, then
create the file with the newest version + 1.
:param filename: filename of the file
:param file: bytes representation of the file
:return: Whether file was successfully uploaded
"""
return DropboxService.create_file(filename, file)
i = 0
while True:
try:
dbx = dropbox.Dropbox(settings.DROPBOX_OAUTH2_ACCESS_TOKEN)
dbx.files_get_metadata(filename + '_' + str(i))
i = i + 1
except:
break
return DropboxService.create_file(filename + '_' + str(i), file)
@staticmethod
def delete_file(filename: str) -> bool: