Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Download/Upload Assets to AEM using API

chetan001
Level 3
Level 3

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.

 

 

 

6 Replies
Kiran_Vedantam
Community Advisor
Community Advisor

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
Level 3
Level 3

you mean temp folder inside server where AEM is running.

Kiran_Vedantam
Community Advisor
Community Advisor

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 

chetan001
Level 3
Level 3

ok, instead of download then upload to AEM Dam. can I direct use rest imgae url to upload to AEM DAM. any way ?   what you think ?

Kiran_Vedantam
Community Advisor
Community Advisor

So once you receive the data, you cant directly push it to AEM. You need to save it in temp location and push it to AEM

burhanuddinj
Level 1
Level 1

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?l...

Kindly let me know in case of any concerns.