I am trying to download image thumb nails or original from DAM and show on another web page hosted by another server. Here is my Java servlet:
public void downloadImage(String img_name) throws IOException
{
String asset_api = "https://dam.company.com/api/assets/products/" + img_name + "/renditions/cq5dam.thumbnail.319.319.png";
try {
URL url = new URL(asset_api);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("Content-Type", "application/octet-stream");
conn.setRequestProperty("Authorization", "Basic xxxxxxxxx");
conn.setDoOutput(true);
System.out.println("resp=" + conn.getResponseCode() + " - " + conn.getResponseMessage());
......
} catch (Exception ex) {
ex.printStackTrace();
}
}
But it got error: HTTP/1.1 404 Not Found. I can opened asset_api on the browser directly and it absolutely exists and works fine. Do I need to set permission for running AEM HTTP API for account used in this servlet or need some other settings?
Thanks,
James
Solved! Go to Solution.
Views
Replies
Total Likes
Krati,
I found out it's permission issue for the account used in above servlet. When I checked Read ACL for this account in account permission setting page, the above servlet works fine.
Thank you for your time.
James
@jamesc25111500 Assets HTTP API are to perform CRUD operations. The above URL will let you read or view the asset but not download it. However, there is a Download Config which essentially enables the Download Servlet and lets you download the Asset via HTTP call.
Enable Asset Download Servlet: https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/assets/manage/do...
curl command to download:https://experienceleague.adobe.com/en/docs/experience-cloud-kcs/kbarticles/ka-21528
Let me know, if this helps.
Krati,
I found out it's permission issue for the account used in above servlet. When I checked Read ACL for this account in account permission setting page, the above servlet works fine.
Thank you for your time.
James