Class WindowsAzureBlobStorageStrategy
java.lang.Object
de.hybris.platform.azure.media.storage.WindowsAzureBlobStorageStrategy
- All Implemented Interfaces:
MediaStorageInitializer,MediaStorageStrategy
public class WindowsAzureBlobStorageStrategy
extends Object
implements MediaStorageStrategy, MediaStorageInitializer
Strategy which allows to store binaries for Media objects in Windows Azure Blob Store data storage.
Corresponding MediaFolder have to be configured with following properties:
media.folder.{mediaFolderQualifier}.storage.strategy=windowsAzureBlobStorageStrategy
media.folder.{mediaFolderQualifier}.connection=connectionString
media.folder.{mediaFolderQualifier}.public.base.url=publicBaseURL
media.folder.{mediaFolderQualifier}.containerAddress=myContainer
Below is full example for MediaFolder with qualifier win:
media.folder.win.storage.strategy=windowsAzureBlobStorageStrategy media.folder.win.connection=DefaultEndpointsProtocol=http;AccountName=foo;AccountKey=UasidIUAIDUAIODuAOIu9kldaldkaIOAKDa89= media.folder.win.public.base.url=foo.blob.core.windows.net media.folder.win.containerAddress=myContainer
If you have more than one media folders, you can share common settings as follows:
media.globalSettings.windowsAzureBlobStorageStrategy.connection=DefaultEndpointsProtocol=http;AccountName=foo;AccountKey=UasidIUAIDUAIODuAOIu9kldaldkaIOAKDa89= media.globalSettings.windowsAzureBlobStorageStrategy.public.base.url=foo.blob.core.windows.net media.globalSettings.windowsAzureBlobStorageStrategy.containerAddress=myContainer
To control clean on init behavior use following property:
media.globalSettings.windowsAzureBlobStorageStrategy.cleanOnInit = true / false
- Spring Bean ID:
- windowsAzureBlobStorageStrategy
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringassembleLocation(String mediaId, String realFileName) voidchecks if communication with external media storage is possible.voiddelete(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.booleanReturnstrueby default for all storage strategies.voidPrepares media storage on initialization.voidonUpdate()Prepares media storage on update.voidsetCleanOnInit(boolean cleanOnInit) voidsetLocationHashService(MediaLocationHashService locationHashService) 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.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.services.MediaStorageInitializer
failOnInitUpdateError
-
Field Details
-
CONNECTION_STRING_KEY
- See Also:
-
CONTAINER_ADDRESS_KEY
- See Also:
-
-
Constructor Details
-
WindowsAzureBlobStorageStrategy
public WindowsAzureBlobStorageStrategy()
-
-
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
-
assembleLocation
-
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
-
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
-
hasValidMediaFolderName
Description copied from interface:MediaStorageStrategyReturnstrueby 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.- Specified by:
hasValidMediaFolderNamein interfaceMediaStorageStrategy- Parameters:
config- media folder configuration for retrieving media folder qualifier (media folder name)- Returns:
falseotherwise
-
onInitialize
public void onInitialize()Description copied from interface:MediaStorageInitializerPrepares media storage on initialization.- Specified by:
onInitializein interfaceMediaStorageInitializer
-
onUpdate
public void onUpdate()Description copied from interface:MediaStorageInitializerPrepares media storage on update.- Specified by:
onUpdatein interfaceMediaStorageInitializer
-
checkStorageConnection
public void checkStorageConnection()Description copied from interface:MediaStorageInitializerchecks if communication with external media storage is possible.- Specified by:
checkStorageConnectionin interfaceMediaStorageInitializer
-
setCleanOnInit
public void setCleanOnInit(boolean cleanOnInit) -
setLocationHashService
-
setStorageConfigService
-