cancel
Showing results for 
Search instead for 
Did you mean: 

What is the significance of the "attachment=true" in the download URL for media in WCMS ?

0 Kudos

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 ?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

0 Kudos

try with media.getURL2() which contains with out attachment="true" for the given pdf uploaded document else properly decode the URL string.