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.
Solved! Go to Solution.
Views
Replies
Total Likes
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
Hi @Shreyas_tm ,
We need to set Content-Disposition Header something like Content-Disposition: attachment; filename="filename.jpg"
where
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>
Thanks
Thanks! Will check on this.
Hi @MukeshYadav_ I didn't get where do we need to add that piece of code. I tried finding it. But didn't get. Can you please help me on this.
Thanks,
shreyas.
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
Hi,
Please use selector in the url e.g. 'download' to differentiate normal and downloadable assets.
Thanks @MukeshYadav_
Will try this solution.
Views
Likes
Replies
Views
Likes
Replies