How to download image from DAM using AEM HTTP API?
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