Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

This conversation has been locked due to inactivity. Please create a new post.

SOLVED

Upload Assets to AEM using API

Avatar

Level 4

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.

 

@Amit-Tiwari 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi

you can use Asset Java API as well to fetch as inputstream and create assets e.g. below code

 

public String importAsset(String assetUri, ResourceResolver resolver){
    AssetObj assestObj = requestService.getAsset(assetUri);
    InputStream is = assestObj.getAssetAsInputStream();
    String mimeType = assestObj.getMimeType();
    String assetsPath = assestObj.getAssetDamPath();
    AssetManager am = resolver.adaptTo(AssetManager.class);
    Asset asset = am.createAsset(assetsPath, is, mimeType, true);
    resolver.commit();
}
Arun Patidar

AEM LinksLinkedIn

View solution in original post

3 Replies

Avatar

Community Advisor

Avatar

Correct answer by
Community Advisor

Hi

you can use Asset Java API as well to fetch as inputstream and create assets e.g. below code

 

public String importAsset(String assetUri, ResourceResolver resolver){
    AssetObj assestObj = requestService.getAsset(assetUri);
    InputStream is = assestObj.getAssetAsInputStream();
    String mimeType = assestObj.getMimeType();
    String assetsPath = assestObj.getAssetDamPath();
    AssetManager am = resolver.adaptTo(AssetManager.class);
    Asset asset = am.createAsset(assetsPath, is, mimeType, true);
    resolver.commit();
}
Arun Patidar

AEM LinksLinkedIn

Avatar

Level 4

Thanks Arun for your input