core.storage
============

.. py:module:: core.storage

.. autoapi-nested-parse::

   Base module for Storage modules – modular components that store media objects in various locations.

   If you are looking to implement a new storage module, you should subclass the `Storage` class and
   implement the `get_cdn_url` and `uploadf` methods.

   Your module **must** also have two config variables 'path_generator' and 'filename_generator' which
   determine how the key is generated for the media object. The 'path_generator' and 'filename_generator'
   variables can be set to one of the following values:
   - 'flat': A flat structure with no subfolders
   - 'url': A structure based on the URL of the media object
   - 'random': A random structure

   The 'filename_generator' variable can be set to one of the following values:
   - 'random': A random string
   - 'static': A replicable strategy such as a hash

   If you don't want to use this naming convention, you can override the `set_key` method in your subclass.





Module Contents
---------------

.. py:class:: Storage

   Bases: :py:obj:`auto_archiver.core.BaseModule`


   Base class for implementing storage modules in the media archiving framework.

   Subclasses must implement the `get_cdn_url` and `uploadf` methods to define their behavior.


   .. py:method:: store(media: auto_archiver.core.Media, url: str, metadata: auto_archiver.core.Metadata = None) -> None


   .. py:method:: get_cdn_url(media: auto_archiver.core.Media) -> str
      :abstractmethod:


      Returns the URL of the media object stored in the CDN.



   .. py:method:: uploadf(file: IO[bytes], key: str, **kwargs: dict) -> bool
      :abstractmethod:


      Uploads (or saves) a file to the storage service/location.

      This method should not be called directly, but instead through the 'store' method,
      which sets up the media for storage.



   .. py:method:: upload(media: auto_archiver.core.Media, **kwargs) -> bool

      Uploads a media object to the storage service.

      This method should not be called directly, but instead be called through the 'store' method,
      which sets up the media for storage.



   .. py:method:: set_key(media: auto_archiver.core.Media, url: str, metadata: auto_archiver.core.Metadata) -> None

      takes the media and optionally item info and generates a key



