Package de.hybris.platform.media.url
Interface MediaURLStrategy
- All Known Implementing Classes:
LocalMediaWebURLStrategy,S3MediaURLStrategy,WindowsAzureBlobURLStrategy
public interface MediaURLStrategy
Strategy for generating public URLs to Media objects. By default there is one common URL strategy for all medias set
by property media.default.url.strategy and it points to LocalMediaWebURLStrategy. URL strategies may be
attached to any media folder by configuring it in properties file as follows:
media.folder.foo.url.strategy = springBeanOfCustomStrategy
This will override default URL strategy for folder foo. What's more there is possibility to attache more than one URL strategy per folder as follows:
media.folder.foo.url.strategy = springBeanOfCustomStrategy,beanOfOtherCustomStrategy,localMediaWebURLStrategy
In this case by default most left hand side strategy will be chosen for rendering URLs in foo folder, but user can choose different one by placing magic preferredUrlStrategyId key in the session to render URL for particular media as follows:
// SessionService is injected by Spring
final SessionService sessionService;
sessionService.executeInLocalView(new SessionExecutionBody()
{
@Override
public TranslationResult execute()
{
sessionService.setAttribute(MediaManager.PREFERRED_URL_STRATEGY_ID, "someSpecialURLStrategy");
// render URL
final String specialUrl = media.getURL();
}
});
Keep in mind that even if there is only common URL strategy set via media.default.url.strategy data stream is still coming directly from underlying storage strategy.
-
Method Summary
Modifier and TypeMethodDescriptiongetUrlForMedia(MediaStorageConfigService.MediaFolderConfig config, MediaSource mediaSource) Gets specific public URL for media binary data.
-
Method Details
-
getUrlForMedia
Gets specific public URL for media binary data.- Parameters:
config- media folder configurationmediaSource- the wrapper which wraps real Media object- Returns:
- the URL for media
-