Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

[AEM Gems Webinar] Accelerating Experience Manager as a Cloud Service development with Rapid Development Environments

How to download dam images from sightly code?


Level 6


I tried the code mentioned below.

<a href="/content/dam/wknd/images/sample.jpg" download>
  <img src="/content/dam/wknd/images/sample.jpg" alt="sample" width="104" height="142">

 This piece of code opens the image in a new tab, it doesn't download the image to my system.


How to achieve this functionality.

1 Accepted Solution


Correct answer by
Community Advisor

you need to write a filter which add those headers when images are requested.

View solution in original post

7 Replies


Community Advisor

you have to look for Content-Disposition header to achieve that

EXAMPLE, That file is send with these headers:

Content-Type: application/force-download
Content-Disposition: attachment; filename=bike_chase-wallpaper-2560x1600.jpg



Level 6


You mean I have to write servlet and send these data through that servlet.... Content-Type: application/force-download

Content-Disposition: attachment; filename

This code I tried.. it is downloading the image but it shows, image format not supported

try {
            ResourceResolver resourceResolver = request.getResourceResolver();

            Resource assetResource = resourceResolver.getResource("/content/dam/wknd-shared/en/contributors/ayo-ogunseinde-237739.jpg");

            Set<Resource> assetSet = new HashSet<>();

            response.setHeader("Content-Disposition", "attachment; filename=ayo-ogunseinde-237739.jpg");
            assetDownloadService.assetDownload(assetResource, assetSet, true, false, false, null, null, "ayo-ogunseinde-237739.jpg", StringUtils.EMPTY, response.getOutputStream());
        } catch (Exception e) {



Correct answer by
Community Advisor

you need to write a filter which add those headers when images are requested.


Level 5

@arunpatidar  this code looks valid, 

<a href="/content/dam/wknd/images/sample.jpg" download>


Why doesn't this work?


Level 4

Please try 


There is an OSGi Configuration in Felix console named "Apache Sling Content
Disposition Filter" which controls Content Disposition for different mime types based on the path