Package: digital-ocean-spaces
digital-ocean-spacesAn MIT licensed python client for Digital Ocean Spaces with a built in shellTLDRThe client connects to a Digital Ocean region and can list files/directors and download/upload files.
It has a built in terminal shell for verbose commands and navigation, <- Not yet finished.ABOUTInspired byPython3-DigitalOcean-Spaces-Manager-v2-Advanced. An API client was needed for a commercial project and that package was the best contender. Abandoned, riddled with issues and lacking any license for distro and modificaiton, digital_ocean_spaces was built from scratch with an MIT license. Use it, share it and most of all, feel free to modify it, and contribute back.The digital-ocean-spaces package provides a nearly stress free 'Client' class that wraps boto3 to help you connect to Digital Ocean spaces. All it needs is your keys and the name of the server to connect to. Once authorized, the client will hopefuly help you figure out what you're doing wrong.Once you have an authorized client ( server name, public key, secret key,) you should be able to implement it into your existing application like normal.Alternatively, if you want to stay in the console and use verbose commands, you can run .shell() <- Not yet finished.QUICKSTARTINSTALLConsole$pipinstalldigital-ocean-spacesor...$pipinstallgit+git@github.com:ChariotDev/digital-ocean-spaces.gitUSE EXAMPLE# main.pyfromspacesimportClientclient=Client(region_name='sfo3',# Requiredspace_name='my_media',# Optional, can be set in spaces/env.yaml and/or be updated with <client>.set_space(space_name)public_key='foo',# Required, but can set key in spaces/env.yamlsecret_key='bar',# Required, but can set key in spaces/env.yaml# If any of region_name, public_key or secret_key are not provided, Client will override all values with env.yaml values.)LIST AVAILABLE SPACES# main.py## Returns raw response content jsonclient.list_spaces()## Readable versionprint(client.list_spaces(string=True# Returns a fancy string))LIST ALL AVAILABLE FILES# main.py## Returns raw response content jsonclient.list_files(space_name=None# Optional if a space is already set)## Readable versionprint(client.list_spacesspace_name=None# Optional if a space is already setstring=True# Returns a fancy string))## Search/list by path begins with 'foo', 'foo/', 'foo/bar.txt'client.list_files(path="foo/"space_name=None# Optional if a space is already set)DOWNLOAD FILE# main.pyclient.download_file(file_name='foo/bar.txt'destination='downloads/'# Optional, should use a useful directoryspace_name=None# Optional if a space is already set)# Download to -> downloads/foo/bar.txtUPLOAD FILE# main.pyclient.upload_file(file='my/pc/foo/bar.txt'destination='foo/'# Optional, should use a useful directoryrename=None# Optional, file name only, no paths or extentionsspace_name=None# Optional if a space is already set)# Upload to -> foo/bar.txtVERBOSE SHELLconsole$client.shell()TECHNICALCLIENT FUNCTIONS# Creates a Client objectClient<.__init__>(self,region_name=None,space_name=None,public_key=None,secret_key=None)# Updates and stores available spacesClient.refresh_spaces()# Lists available spacesClient.list_spaces(self,string=False)# Sets active spaceClient.set_space(self,space_name)# Updates and stores available filesClient.refresh_files(self,space_name=None)# Lists only the available directoriesClient.list_dirs(self,path='',space_name=None,string=False)# Lists only the available filesClient.list_files(self,path='',space_name=None,string=False)# Lists all files and directoriesClient.list_all(self,path='',space_name=None,string=False)# Downloads specified fileClient.download_file(self,file_name,destination="downloads/",space_name=None)# Uploads specified fileClient.upload_file(self,file,destination="",rename=None,space_name=None,extra_args={})# extra_args: see https://boto3.amazonaws.com/v1/documentation/api/latest/guide/s3-uploading-files.html# Deletes specified fileClient.delete_file(self,file_path,yes=False,space_name=None)# Starts verbose shellClient.shell(self)CHANGELOG0.2.4bugfix in list_dirs0.2.4bugfix in delete_file0.2.3add extra_args to upload_file0.2.2added error to upload_file to prevent file name in destination path0.2.1remove pkg-resources==0.0.0 dependencyrebuild requirement.txt0.2.0dir kwarg renamed to path, moved to the first positional arg in: list_files, list_dirs, list_allspace_files will populate upon client instance if space_name is supplied.added delete_file function0.1.5Fixed manifest0.1.2Add region name field to env.yamlAdd default space field to env.yamlRenamed import module to spaces for simplicity0.1.1Documentation0.1.0Initial release