Uploading image from Tomcat to Dam | Community
Skip to main content
Level 2
Dec 15, 2017 1:07 PM UTC
Solved

Uploading image from Tomcat to Dam

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");

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
joerghoh
joerghohAccepted solution
Employee
Dec 19, 2017 9:20 PM UTC

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

8 replies

joerghoh
joerghohAccepted solution
Employee
Dec 19, 2017 9:20 PM UTC

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

Translate
smacdonald2008
Level 10
Dec 19, 2017 8:33 PM UTC

I would revert to the API that works and log a bug against the new API.

Translate
Level 2
Dec 19, 2017 1:36 PM UTC

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

Translate
VeenaVikraman
New Participant
Dec 18, 2017 3:06 PM UTC

Can you send the error log you are getting ?

Translate
Level 2
Dec 18, 2017 6:00 AM UTC

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.

Translate
Level 2
Dec 18, 2017 5:58 AM UTC

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

Translate
smacdonald2008
Level 10
Dec 15, 2017 6:50 PM UTC

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.

Translate
VeenaVikraman
New Participant
Dec 15, 2017 5:28 PM UTC

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 ?

Translate