Download/Upload Assets to AEM using API | Community
Skip to main content
chetan001
Level 3
November 25, 2021

Download/Upload Assets to AEM using API

  • November 25, 2021
  • 2 replies
  • 5367 views

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.

2 replies

Kiran_Vedantam
Community Advisor
Community Advisor
November 25, 2021

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.

chetan001
chetan001Author
Level 3
November 25, 2021

you mean temp folder inside server where AEM is running.

Kiran_Vedantam
Community Advisor
Community Advisor
November 25, 2021

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 

burhanuddinj
Level 2
November 29, 2021

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.

 

 

 

Level 4
October 10, 2022

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