Expand my Community achievements bar.

SOLVED

Exposing assets to end user

Avatar

Level 4

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.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@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..  

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

@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..  

Avatar

Community Advisor

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-ap...

[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... 

 



Esteban Bustamante