Package de.hybris.platform.media.storage
Interface MediaStorageStrategy
- All Known Implementing Classes:
GridFSMediaStorageStrategy,LocalFileMediaStorageStrategy,S3MediaStorageStrategy,WindowsAzureBlobStorageStrategy
public interface MediaStorageStrategy
Strategy for manipulating media binary data. Each binary data connected to
Media object is stored in
media storage which could be any storage like for instance file system, disk share, FTP. Binary data is identified by
its unique location string identifier. After storing binary data by using
store(de.hybris.platform.media.storage.MediaStorageConfigService.MediaFolderConfig, java.lang.String, java.util.Map, java.io.InputStream)
StoreMediaData object is returned which contains all required informations: unique location string
identifier, size and hash for location. All other operations like: delete, get can be performed by using unique
location string identifier.-
Method Summary
Modifier and TypeMethodDescriptionvoiddelete(MediaStorageConfigService.MediaFolderConfig config, String location) Delete media represented by location from the storage.getAsFile(MediaStorageConfigService.MediaFolderConfig config, String location) Gets the media data from the storage as file.getAsStream(MediaStorageConfigService.MediaFolderConfig config, String location) Gets the media data from the storage as stream.longgetSize(MediaStorageConfigService.MediaFolderConfig config, String location) Gets size of media data in bytes.default booleanReturnstrueby default for all storage strategies.store(MediaStorageConfigService.MediaFolderConfig config, String mediaId, Map<String, Object> metaData, InputStream dataStream) Stores media data into the storage using unique location identifier.
-
Method Details
-
store
StoredMediaData store(MediaStorageConfigService.MediaFolderConfig config, String mediaId, Map<String, Object> metaData, 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 amediaIdas unique part.mediaIdis generated by platform for each upload attempt so it guarantees uniqueness.- Parameters:
config- media folder configurationmediaId- the media identifiermetaData- the meta data containing additional possible informations like: original filename, MIME, folder pathdataStream- 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
Delete media represented by location from the storage.- Parameters:
config- media folder configurationlocation- the string representation of location of media data in storage- Throws:
MediaRemovalException- if delete operation in the storage has failed
-
getAsStream
Gets the media data from the storage as stream.- Parameters:
config- media folder configurationlocation- the string representation of location of media data in storage- Returns:
- the data
- Throws:
MediaNotFoundException- when media does not exist in the storage
-
getAsFile
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 configurationlocation- the string representation of location of media data in storage- Returns:
- the media as file
- Throws:
UnsupportedOperationException- when particular implementation does not support returning data as File
-
getSize
Gets size of media data in bytes.- Parameters:
config- media folder configurationlocation- 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
-
hasValidMediaFolderName
Returnstrueby default for all storage strategies. If storage strategy requires special media folder naming convention (eg. for evaluating container name) then overrides this method and returns true if media folder name complies with strategy's requirements.- Parameters:
config- media folder configuration for retrieving media folder qualifier (media folder name)- Returns:
falseotherwise
-