Download option Functionality. | Community
Skip to main content
Level 3
August 29, 2024
Solved

Download option Functionality.

  • August 29, 2024
  • 1 reply
  • 1136 views

So in one of the scenario we are having an image/video and download option for it. So whenever we click on that download button/logo the image gets downloaded. We checked this thing on Local author and local publish instance and it worked as expected. But on DEV, STAGE and PROD it worked only on author instance. It didn't work as expected on publisher and dispatcher instances.

Issue: When we click on that download option, the image/video opens in new tab, but doesn't get downloaded.

 

Any insights on this.

 

Thanks,

Shreyas.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by MukeshYadav_

Hi @shreyas_tm ,

These are dispatcher rules we can write in vhost file

eg.  dispatcher/src/conf.d/available_vhosts/projectname.vhost

<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/html

# Other directives

<LocationMatch "\.(?i:jpg|jpeg|png|gif|bmp|webp)$">
ForceType application/octet-stream
Header set Content-Disposition "attachment; filename=\"default-image.jpg\""
</LocationMatch>

<LocationMatch "\.(?i:mp4|avi|mov|mkv)$">
ForceType application/octet-stream
Header set Content-Disposition "attachment; filename=\"default-video.mp4\""
</LocationMatch>

# Other directives
</VirtualHost>

Thanks

1 reply

MukeshYadav_
Community Advisor
Community Advisor
August 29, 2024

Hi @shreyas_tm ,

We need to set Content-Disposition Header something like Content-Disposition: attachment; filename="filename.jpg"

where

  • attachment   - to download the asset
  • inline         - to open in browser

Rule can be written path specific with help of LocationMatch.

For example

 

<LocationMatch "\.(?i:jpg|jpeg|png|gif|bmp|webp)$"> ForceType application/octet-stream Header set Content-Disposition "attachment; filename=\"default-image.jpg\"" </LocationMatch> <LocationMatch "\.(?i:mp4|avi|mov|mkv)$"> ForceType application/octet-stream Header set Content-Disposition "attachment; filename=\"default-video.mp4\"" </LocationMatch>

 

References https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/content-disposition-on-aem-as-cloud/m-p/435636

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem-6-5-asset-direct-link-downloads-does-not-open-asset-in/m-p/352366

Thanks

Level 3
August 29, 2024

Hi @mukeshyadav_ 

Thanks! Will check on this.