sams.storage.providers.base – Base Storage Provider

Storage Provider base is a…..

The sams.storage.providers.base package provides storage io implementations.

class SamsBaseStorageProvider(config_string: str)

An instance of SamsBaseStorageProvider

process_config_string(config_string: str)

Extract relevant information from the provided config_string

Parameters

config_string (str) – A string from any STORAGE_DESTINATION config attribute

Raises

ValueError – If there

exists(media_id: Union[bson.objectid.ObjectId, str])bool

Checks if a file exists in the storage destination

This method must be defined in the derived class

Parameters

media_id – The ID of the asset

Returns

True if a matching file exists, False otherwise

Raises

NotImplementedError – If not defined in derived class

put(content: Union[BinaryIO, str], filename: str, mimetype: Optional[str] = None)str

Upload a file to the storage destination

content must be an instance of bytes or a file-like object providing a read() method.

This method must be defined in the derived class

Parameters
  • content (bytes) – The data to be uploaded

  • filename (str) – The filename

  • mimetype (str) – The mimetype of the content

Returns

The "id" of the created file

Raises

NotImplementedError – If not defined in derived class

get(media_id: Union[bson.objectid.ObjectId, str])superdesk.storage.superdesk_file.SuperdeskFile

Get an asset from the storage

This method must be defined in the derived class

Parameters

media_id – The ID of the asset

Returns

Raises

NotImplementedError – If not defined in derived class

delete(media_id: Union[bson.objectid.ObjectId, str])

Delete as asset from the storage

This method must be defined in the derived class

Parameters

media_id – The ID of the asset

Raises

NotImplementedError – If not defined in derived class

drop()

Deletes all assets from the storage

This method must be defined in the derived class

Raises

NotImplementedError – If not defined in derived class