on 06-19-2014 12:34 PM
We have migrated our application from hybris 4.4 to hyrbis 5.1. The download URL for any media in WCMS is like , "/medias/sys_master/8802742894622/hppromo-2014colorofyear.png&attachment=true" As a result, the media is not getting downloaded unless one should remove "attachment=true" manually. The class LocalMediaWebURLStrategy contains following method :
public String getDownloadUrlForMedia(MediaStorageConfigService.MediaFolderConfig config, MediaSource mediaSource) { StringBuilder url = new StringBuilder(getUrlForMedia(config, mediaSource)); if (this.prettyUrlEnabled) { url.append("?"); } else { url.append("&"); } url.append("attachment").append("=").append("true"); return url.toString(); }
Will it cause any other functionality to break if we remove the "attachement=true" by overriding the same method ? What is the significance of the same ?
hi adrien, Actually in our case we have a media created for product image but we do not upload the image in media instead we use direct thirdparty url. due to this the image is not loading in cockpit The reason is due to the below code
private String assembleUrl(String folderQualifier, MediaSource mediaSource) { String result = ""; if ((!(GenericValidator.isBlankOrNull(folderQualifier))) && (!(GenericValidator.isBlankOrNull(mediaSource.getLocation())))) { if (this.prettyUrlEnabled) { result = assembleLegacyURL(folderQualifier, mediaSource); } else { result = assembleURLWithMediaContext(folderQualifier, mediaSource); } } return result; }
Due to the validation mediasource.getloaction fails for our media the url is not returned from the above method.
Please advise on how to fix the issue. thank you in advance
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The attachment=true adds the Content-Disposition:", " attachment; filename=xxx
header to the HttpResponse containing the media which forces the browser to display the download dialog. That is usually what you need for document media (spreadsheet or PDF for example). For images, that gives unwanted behavior.
If you use media.getURL()
(or MediaService.getUrlForMedia()
) instead of media.getDownloadURL()
, you'll get the proper URL without the attachment=true.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.