Hi I am trying to upload an image from tomcat to AEM 6.3 DAM. But seems createAsset method of package com.adobe.granite.asset.api.AssetManager is not working as expected. Could anyone please help me as I am able to upload the image if I am using method from com.day.cq.dam.api.AssetManager pthis package.
My code below
HttpURLConnection con = null;
AssetManager assetManager = resolver.adaptTo(AssetManager.class);
URL urlObj = new URL(assetUrl);
con = (HttpURLConnection) urlObj.openConnection();
con.setRequestMethod("GET");
InputStream is = con.getInputStream();
Asset asset = assetManager.createAsset(path);
Map<String, Object> map = new HashMap<>();
map.put(RenditionHandler.PROPERTY_RENDITION_MIME_TYPE, "image/jpeg");
asset.setRendition("original", is, map);
Method Call :-
.downloadAndSaveAsset(resolver, "http://localhost:8080/images/new1.jpg",
"/content/dam/new-folder/new1.jpg");
Solved! Go to Solution.
I don't think it's a bug in the new API.
The Granite AssetManager doesn't seem to be related to the CQ DAM AssetManager API (besides the name and the similarity of some methods). The most important aspect is that the CQ DAM AssetManager is not deprecated and therefor a fully supported API. I would stick with it and check how the Granite AssetManager API evolves in the next versions of AEM.
Jörg
What exactly are you trying to achieve here ? I do see the URL you mentioned here is your localhost. Can you first check if the connection is established proper;y ? are you getting valid connection objects and if your inputstream has valid data ?
If all are fine and if you are getting any error , can you paste your error log to check what exactly is wrong here ?
Views
Replies
Total Likes
To upload a image from outside of AEM - write a servlet that uses the Asset Manager API and then post the file to the servlet.
Scott's Digital Community: Uploading files to Adobe Experience Manager DAM using AssetManager API
See the Java Servlet code that uses Asset Manager API.
Views
Replies
Total Likes
Hi Veena,
I am trying to save an image from Tomcat server to AEM DAM. Connection is getting established even image is getting uploaded if I use the method create Assest from the Old API com.day.cq.dam.api.AssetManager.
But when I am using the new API com.adobe.granite.asset.api.AssetManager CreateAssest method which accepts only one parameter my image is not getting uploaded. Even I am not getting any error in error logs also
Views
Replies
Total Likes
Hi Scott,
I am able to upload the image by using old API com.day.cq.dam.api.AssetManager create assest method. My concern is I am not able to do the same if I am using the createAssest method of new API com.adobe.granite.asset.api.AssetManager.
Views
Replies
Total Likes
Can you send the error log you are getting ?
Views
Replies
Total Likes
I am not getting any error in logs. It is succesfully printing the next line. Even if I try retrieving the same assest from Resource by giving the path I am able to get it. But I could not see that image in CRX
Views
Replies
Total Likes
I would revert to the API that works and log a bug against the new API.
Views
Replies
Total Likes
I don't think it's a bug in the new API.
The Granite AssetManager doesn't seem to be related to the CQ DAM AssetManager API (besides the name and the similarity of some methods). The most important aspect is that the CQ DAM AssetManager is not deprecated and therefor a fully supported API. I would stick with it and check how the Granite AssetManager API evolves in the next versions of AEM.
Jörg
Views
Likes
Replies
Views
Likes
Replies