Exposing assets to end user | Community
Skip to main content
Uppari_Ramesh
Level 5
September 28, 2023
Solved

Exposing assets to end user

  • September 28, 2023
  • 2 replies
  • 652 views

Hi Team

 

Would like know what is the best way of exposing assets under /content/test  to the end user other than assets api. I need to provide link of asset to end user via servlet response and when user clicks on the link asset should get download.

 

Thanks.

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 A_H_M_Imrul

@uppari_ramesh 

I am a bit confused about the path (/content/test) that you want to put assets under. 

However, there are multiple ways to share/expose assets with the end user

- for any user -> the asset path under /dam needs accessible by the anonymous user group (Read Permission)

- for selected users -> create a service user and provide Read access to the asset path for that service user. Assign this service user to the actual user while logging in.

 

If you can share the business you want to achieve, will be able to help better..  

2 replies

A_H_M_Imrul
Community Advisor
A_H_M_ImrulCommunity AdvisorAccepted solution
Community Advisor
September 28, 2023

@uppari_ramesh 

I am a bit confused about the path (/content/test) that you want to put assets under. 

However, there are multiple ways to share/expose assets with the end user

- for any user -> the asset path under /dam needs accessible by the anonymous user group (Read Permission)

- for selected users -> create a service user and provide Read access to the asset path for that service user. Assign this service user to the actual user while logging in.

 

If you can share the business you want to achieve, will be able to help better..  

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
September 28, 2023

The best approach would be to utilize what is available out of the box (OOTB) and avoid customizing anything else. This involves using the Assets API[1] and moving your assets to a folder under "/content/dam," for example, "/content/dam/test." You can still use ACLs to secure this folder as needed. Personally, I don't see a reason to store assets directly under "/content," as this is considered a bad practice. However, if you choose not to follow the best approach, you can simply write a servlet to iterate through the children of your asset folder and return a list of assets.

 

For the downloading functionality, you must ensure that the assets are accessed through the dispatcher and not directly on a publish or author server, this again is the best practice. When using the dispatcher, achieving the download functionality is straightforward. You need to ensure that the dispatcher adds the header "Content-Disposition: attachment" which is the default behavior if the assets are not cached[2]. This will work whether you create a custom servlet or go with the Assets API approach.

 

[1]. https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/assets/admin/mac-api-assets.html?lang=en#retrieve-a-folder-listing

[2]. http://www.sgaemsolutions.com/2019/10/aempdf-is-getting-downloded-instead-of.html 

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

 

Esteban Bustamante