Interface MediaStorageStrategy

    • Method Detail

      • store

        StoredMediaData store​(MediaStorageConfigService.MediaFolderConfig config,
                              java.lang.String mediaId,
                              java.util.Map<java.lang.String,​java.lang.Object> metaData,
                              java.io.InputStream dataStream)
        Stores media data into the storage using unique location identifier. Location identifier is computed by each implementation in different way which depends on API of underlying media storage but in most cases contains a mediaId as unique part. mediaId is generated by platform for each upload attempt so it guarantees uniqueness.
        Parameters:
        config - media folder configuration
        mediaId - the media identifier
        metaData - the meta data containing additional possible informations like: original filename, MIME, folder path
        dataStream - the data stream to store
        Returns:
        object containing information about stored data like unique location in the storage, size and hash for location
        Throws:
        MediaStoreException - when media stream cannot be stored in storage
      • delete

        void delete​(MediaStorageConfigService.MediaFolderConfig config,
                    java.lang.String location)
        Delete media represented by location from the storage.
        Parameters:
        config - media folder configuration
        location - the string representation of location of media data in storage
        Throws:
        MediaRemovalException - if delete operation in the storage has failed
      • getAsStream

        java.io.InputStream getAsStream​(MediaStorageConfigService.MediaFolderConfig config,
                                        java.lang.String location)
        Gets the media data from the storage as stream.
        Parameters:
        config - media folder configuration
        location - the string representation of location of media data in storage
        Returns:
        the data
        Throws:
        MediaNotFoundException - when media does not exist in the storage
      • getAsFile

        java.io.File getAsFile​(MediaStorageConfigService.MediaFolderConfig config,
                               java.lang.String location)
        Gets the media data from the storage as file. Note that implementation of this method may be optional when underlying media storage does not support downloading data as File.
        Parameters:
        config - media folder configuration
        location - the string representation of location of media data in storage
        Returns:
        the media as file
        Throws:
        java.lang.UnsupportedOperationException - when particular implementation does not support returning data as File
      • getSize

        long getSize​(MediaStorageConfigService.MediaFolderConfig config,
                     java.lang.String location)
        Gets size of media data in bytes.
        Parameters:
        config - media folder configuration
        location - the string representation of location of media data in storage
        Returns:
        the size of an media data in bytes
        Throws:
        MediaNotFoundException - when media does not exist in the storage