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
BedrockMission!

Learn More

View all

Sign in to view all badges

How to update asset programatically in AEM Assets?

Avatar

Avatar
Validate 1
Level 1
arunaaems506124
Level 1

Like

1 like

Total Posts

25 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Give Back
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
arunaaems506124
Level 1

Like

1 like

Total Posts

25 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Give Back
Boost 1
Applaud 5
View profile
arunaaems506124
Level 1

01-07-2020

Hi All,

 

I am using createAsset Api to create asset in asset server.If I want to  update asset content (I am uplaoding pdfs) file is not updating. How to achieve file update with assetmanager API.

 

Any help much appreaciated.

 

AssetManager manager = resourceResolver.adaptTo(AssetManager.class);
Asset createAsset(String path,
                InputStream is,
                String mimeType,
                boolean doSave)

 

Thanks!

 

View Entire Topic

Avatar

Avatar
Give Back 5
Employee
sunjot16
Employee

Likes

105 likes

Total Posts

164 posts

Correct Reply

50 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 25
Give Back 10
Give Back
View profile

Avatar
Give Back 5
Employee
sunjot16
Employee

Likes

105 likes

Total Posts

164 posts

Correct Reply

50 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 25
Give Back 10
Give Back
View profile
sunjot16
Employee

03-07-2020

You can use the Asset Interface to achieve the same.

     // to create an asset
     AssetManager assetManager = resolver.adaptTo(AssetManager.class);
     Asset newAsset = assetManager.createAsset("/path/to/asset/document.pdf");

The following docs may be helpful:

https://helpx.adobe.com/experience-manager/6-4/sites/developing/using/reference-materials/javadoc/co...

https://helpx.adobe.com/experience-manager/6-4/sites/developing/using/reference-materials/javadoc/co...

 

The latter one states: 

Creates a new Asset at the given path. If an asset already exists at the given path, its original rendition is updated instead of creating a new asset. If inputStream is null new Asset is created without original rendition. If an asset already exists at given path and inputstream is null, original rendition is not updated.

 

I think that your Input Stream is null, due to which the original rendition is not getting updated.

Input Stream is the input stream of the new asset's original binary.

 

You can also achieve the same using Assets HTTP API, as follows:

https://docs.adobe.com/content/help/en/experience-manager-65/assets/extending/mac-api-assets.html#cr...

https://docs.adobe.com/content/help/en/experience-manager-65/assets/extending/mac-api-assets.html#up...

 

Hope these help !!