S3 Storage Utils#

Module created for s3 linkage in settings files.

class federated_learning_project.s3_storage_utils.StaticStorage(*args, **kwargs)#

Bases: S3Boto3Storage

Class used for linkage to s3 bucket for settings file.

bucket_name = 'fma-serverless-storage'#
location = 'static'#
access_key_names = ['AWS_S3_ACCESS_KEY_ID', 'AWS_ACCESS_KEY_ID']#
property bucket#

Get the current bucket. If there is no current bucket object create it.

config = None#
property connection#
deconstruct()#

Return a 3-tuple of class import path, positional arguments, and keyword arguments.

default_content_type = 'application/octet-stream'#
delete(name)#

Delete the specified file from the storage system.

exists(name)#

Return True if a file referenced by the given name already exists in the storage system, or False if the name is available for a new file.

generate_filename(filename)#

Validate the filename by calling get_valid_name() and return a filename to be passed to the save() method.

get_accessed_time(name)#

Return the last accessed time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True.

get_alternative_name(file_root, file_ext)#

Return an alternative filename, by adding an underscore and a random 7 character alphanumeric string (before the file extension, if one exists) to the filename.

get_available_name(name, max_length=None)#

Overwrite existing file with the same name.

get_cloudfront_signer(key_id, key)#
get_created_time(name)#

Return the creation time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True.

get_default_settings()#
get_modified_time(name)#

Returns an (aware) datetime object containing the last modified time if USE_TZ is True, otherwise returns a naive datetime in the local timezone.

get_object_parameters(name)#

Returns a dictionary that is passed to file upload. Override this method to adjust this on a per-object basis to set e.g ContentDisposition.

By default, returns the value of AWS_S3_OBJECT_PARAMETERS.

Setting ContentEncoding will prevent objects from being automatically gzipped.

get_valid_name(name)#

Return a filename, based on the provided filename, that’s suitable for use in the target storage system.

listdir(name)#

List the contents of the specified path. Return a 2-tuple of lists: the first item being directories, the second item being files.

modified_time(name)#

Returns a naive datetime object containing the last modified time.

open(name, mode='rb')#

Retrieve the specified file from storage.

path(name)#

Return a local filesystem path where the file can be retrieved using Python’s built-in open() function. Storage systems that can’t be accessed using open() should not implement this method.

save(name, content, max_length=None)#

Save new content to the file specified by name. The content should be a proper File object or any Python file-like object, ready to be read from the beginning.

secret_key_names = ['AWS_S3_SECRET_ACCESS_KEY', 'AWS_SECRET_ACCESS_KEY']#
security_token = None#
security_token_names = ['AWS_SESSION_TOKEN', 'AWS_SECURITY_TOKEN']#
size(name)#

Return the total size, in bytes, of the file specified by name.

url(name, parameters=None, expire=None, http_method=None)#

Return an absolute URL where the file’s contents can be accessed directly by a web browser.