Class LocalFileMediaStorageStrategy
java.lang.Object
de.hybris.platform.media.storage.impl.LocalFileMediaStorageStrategy
- All Implemented Interfaces:
LocalStoringStrategy,MediaStorageStrategy
public class LocalFileMediaStorageStrategy
extends Object
implements MediaStorageStrategy, LocalStoringStrategy
Strategy which allows to store binaries for Media objects locally in data directory of current platform
installation. This strategy supports flat as well as hierarchical way of file storing.
Corresponding MediaFolder have to be configured with following properties:
media.folder.{mediaFolderQualifier}.storage.strategy=localFileMediaStorageStrategy
media.folder.{mediaFolderQualifier}.hashing.depth=depth
where mediaFolderQualifier is qualifier of MediaFolder and depth is possible depth for subfolder structure. Below is full example for MediaFolder with qualifier foo and depth 2:
media.folder.foo.storage.strategy=localFileMediaStorageStrategy media.folder.foo.hashing.depth=2
Strategy can be also configured globally as follows:
media.default.storage.strategy=localFileMediaStorageStrategy media.default.hashing.depth=2
To control clean on init behavior use following property:
media.globalSettings.localFileMediaStorageStrategy.cleanOnInit = true / false
- Spring Bean ID:
- localFileMediaStorageStrategy
-
Field Summary
Fields -
Constructor Summary
Constructors -
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.protected booleanvoidsetLocationHashService(MediaLocationHashService locationHashService) voidsetMainDataDir(File mainDataDir) voidsetMediaService(MediaService mediaService) voidsetMimeService(MimeService mimeService) voidsetReplicationDirs(List<File> replicationDirs) voidsetStorageConfigService(MediaStorageConfigService storageConfigService) store(MediaStorageConfigService.MediaFolderConfig config, String mediaId, Map<String, Object> metaData, InputStream dataStream) Stores media data into the storage using unique location identifier.protected voidverifyFolderAndLocationIntegrity(MediaStorageConfigService.MediaFolderConfig config, String location) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.hybris.platform.media.storage.MediaStorageStrategy
hasValidMediaFolderName
-
Field Details
-
FOLDER_INTEGRITY_VERIFICATION_ENABLED_FLAG
- See Also:
-
storageConfigService
-
-
Constructor Details
-
LocalFileMediaStorageStrategy
public LocalFileMediaStorageStrategy()
-
-
Method Details
-
store
public StoredMediaData store(MediaStorageConfigService.MediaFolderConfig config, String mediaId, Map<String, Object> metaData, InputStream dataStream) Description copied from interface:MediaStorageStrategyStores 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.- Specified by:
storein interfaceMediaStorageStrategy- 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
-
delete
Description copied from interface:MediaStorageStrategyDelete media represented by location from the storage.- Specified by:
deletein interfaceMediaStorageStrategy- Parameters:
config- media folder configurationlocation- the string representation of location of media data in storage
-
getAsStream
Description copied from interface:MediaStorageStrategyGets the media data from the storage as stream.- Specified by:
getAsStreamin interfaceMediaStorageStrategy- Parameters:
config- media folder configurationlocation- the string representation of location of media data in storage- Returns:
- the data
-
verifyFolderAndLocationIntegrity
protected void verifyFolderAndLocationIntegrity(MediaStorageConfigService.MediaFolderConfig config, String location) -
isFolderVerificationDisabled
protected boolean isFolderVerificationDisabled() -
getAsFile
Description copied from interface:MediaStorageStrategyGets 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.- Specified by:
getAsFilein interfaceMediaStorageStrategy- Parameters:
config- media folder configurationlocation- the string representation of location of media data in storage- Returns:
- the media as file
-
getSize
Description copied from interface:MediaStorageStrategyGets size of media data in bytes.- Specified by:
getSizein interfaceMediaStorageStrategy- Parameters:
config- media folder configurationlocation- the string representation of location of media data in storage- Returns:
- the size of an media data in bytes
-
setStorageConfigService
-
setMainDataDir
-
setReplicationDirs
-
setLocationHashService
-
setMimeService
-
setMediaService
-