Skip to main content
chetan001
Level 3
Nov 25, 2021 2:36 PM UTC

Download/Upload Assets to AEM using API

Hi All,

 

I am integrating AEM with rest service which is providing image/asset urls .  using this url ,I have to get image and this image should upload to AEM DAM System.

 

I am planning to  download image in aem root/folder path using http client api. Then using AEM Assets http Api  will upload to dam folder.

 

Is this approach fine ? 

 

Could you please share best approach to implement this kind of scenario.

 

Appreciate your comments.

 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

7 replies

Kiran_Vedantam
Community Advisor
Community Advisor
Nov 25, 2021 2:44 PM UTC

Hi @chetan001 

 

After downloading the assets, instead of downloading and keeping it in root folder, create temp file, push it to AEM DAM and delete the temp file.

 

You can use java.io.file API for this.

 

Hope this helps!

Thanks,

Kiran Vedantam.

Translate
chetan001
chetan001Author
Level 3
Nov 25, 2021 2:52 PM UTC

you mean temp folder inside server where AEM is running.

Translate
Kiran_Vedantam
Community Advisor
Community Advisor
Nov 25, 2021 3:00 PM UTC

If you use the API, it should automatically create a temp file for you. Use the below code

 

//Create
File sample = File.createTempFile("sample", ".pdf");
//Delete
Files.delete(sample.toPath());

Hope this helps.

 

Thanks,

Kiran Vedantam 

Translate
burhanuddinj
Level 2
Nov 29, 2021 6:51 AM UTC

Hi @chetan001 ,

If the REST API is providing you Image data in binary format then you can directly use AEM Asset API to upload the asset in AEM.

You need to pass the binary data in request body and Asset API will upload it in specified location.

https://experienceleague.adobe.com/docs/experience-manager-65/assets/extending/mac-api-assets.html?lang=en

Kindly let me know in case of any concerns.

 

 

 

Translate
Level 4
Oct 10, 2022 12:20 PM UTC

What if I have a public web url? Can AEM do the heavy lifting on behalf of me?

Translate