public interface MediaURLStrategy
media.folder.foo.url.strategy = springBeanOfCustomStrategyThis 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,localMediaWebURLStrategyIn 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.| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getUrlForMedia(MediaStorageConfigService.MediaFolderConfig config,
MediaSource mediaSource)
Gets specific public URL for media binary data.
|
java.lang.String getUrlForMedia(MediaStorageConfigService.MediaFolderConfig config, MediaSource mediaSource)
config - media folder configurationmediaSource - the wrapper which wraps real Media objectCopyright © 2018 SAP SE. All Rights Reserved.