Package de.hybris.platform.media.storage
Interface MediaStorageStrategy
-
- All Known Implementing Classes:
GridFSMediaStorageStrategy,LocalFileMediaStorageStrategy,S3MediaStorageStrategy,WindowsAzureBlobStorageStrategy
public interface MediaStorageStrategyStrategy for manipulating media binary data. Each binary data connected toMediaobject is stored in media storage which could be any storage like for instance file system, disk share, FTP. Binary data is identified by its uniquelocationstring identifier. After storing binary data by usingstore(de.hybris.platform.media.storage.MediaStorageConfigService.MediaFolderConfig, java.lang.String, java.util.Map, java.io.InputStream)StoreMediaDataobject 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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voiddelete(MediaStorageConfigService.MediaFolderConfig config, java.lang.String location)Delete media represented by location from the storage.java.io.FilegetAsFile(MediaStorageConfigService.MediaFolderConfig config, java.lang.String location)Gets the media data from the storage as file.java.io.InputStreamgetAsStream(MediaStorageConfigService.MediaFolderConfig config, java.lang.String location)Gets the media data from the storage as stream.longgetSize(MediaStorageConfigService.MediaFolderConfig config, java.lang.String location)Gets size of media data in bytes.StoredMediaDatastore(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.
-
-
-
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 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
void delete(MediaStorageConfigService.MediaFolderConfig config, java.lang.String location)
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
java.io.InputStream getAsStream(MediaStorageConfigService.MediaFolderConfig config, java.lang.String location)
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
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 configurationlocation- 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 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
-
-