Creating an AEM asset programmatically on AEMaaCS using Java, but it fails to generate previews/renditions | Community
Skip to main content
March 30, 2025

Creating an AEM asset programmatically on AEMaaCS using Java, but it fails to generate previews/renditions

  • March 30, 2025
  • 3 replies
  • 1489 views

 

We are programmatically creating an AEM DAM asset in AEM as a Cloud Service (AEMaaCS) using the Node API and adding required path and properties for assets.

Node childNode =JcrUtil.createPath(path, SyncAssetWithMetadataFromDAMConstants.SLING_ORSEREDFOLDER, DamConstants.NT_DAM_ASSET, session, true); Node jcrContentNode = getOrCreateNode(childNode, SyncAssetWithMetadataFromDAMConstants.JCR_CONTENT, SyncAssetWithMetadataFromDAMConstants.NT_UNSTRUCTURED); Node metadataNode = getOrCreateNode(jcrContentNode, SyncAssetWithMetadataFromDAMConstants.METADATA, SyncAssetWithMetadataFromDAMConstants.NT_UNSTRUCTURED); .......... asset.setRendition(SyncAssetWithMetadataFromDAMConstants.ORIGINAL_RENDITION, binary, renditionProperties);

If we manually reprocess the asset via the AEM UI, then the preview/renditions are generated correctly, and the asset becomes fully usable.

 

Que: Can we trigger the 'Asset Processor' custom workflow process step in a custom workflow and invoke it from our code after creating the asset? & In the screenshot, it was mentioned that this should be confirmed by the Adobe engineering team.

 

Any guidance on how to correctly integrate asset processing into our programmatic asset creation flow would be greatly appreciated!

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

3 replies

giuseppebaglio
Level 10
March 31, 2025

Instead of using the Node API to create the asset, I recommend leveraging the AssetManager.createOrUpdateAsset method:

"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 binary is null new Asset is created without original rendition. If an asset already exists at given path, original rendition is not updated."

I have tested this method with binary input and I confirm that the out-of-the-box workflows are triggered automatically.

New Member
April 1, 2025

AssetManager.createOrUpdateAsset method is deprecated in latest SDK @giuseppebaglio

That is why, we were thinking to use pre-process step as asked above.

Community Advisor
March 31, 2025

In AEM as a Cloud, the Asset API's to create the assets are now deprecated. Have you tried with the new cloud approach to upload the assets? Refer here for more details - https://medium.com/tech-learnings/uploading-assets-in-aem-as-a-cloud-service-a-complete-guide-67bf347eab70?sk=1e08d3098095ca699f79384d36fa5363

Regards

Albin

https://myprofile.albinsblog.com

New Member
April 1, 2025

hi @albinis1  - we noticed that upload API usually is taking a lot of time even for creating 1 image of 50MB, so thought of exploring more options. 

sarav_prakash
Community Advisor
Community Advisor
April 29, 2025

Hi @user65860 , 

Albin points the correct way. Donot use AssetManager or Node API or Java APIs. Definitely not going to work. 

I too wrote a detailed article explaining problems with java API https://medium.com/@bsaravanaprakash/how-we-migrated-a-million-assets-into-aem-cloud-service-dam-ef7eb74d30fa

 

Correct way is explained here https://experience-aem.blogspot.com/2021/06/aem-cloud-service-sample-java-standalone-program-upload-assets.html?m=1 

Its not slow, its complete. Donot try to split upload process and custom implement.

Extending asset compute service is allowed. But should not break asset integrity as you started above. 

If node API appears faster than AssetCompute, it means its incomplete. Not recommended, even thought it appears to work. 

kautuk_sahni
Community Manager
Community Manager
April 1, 2025

@user65860 Did you find the suggestions helpful? Please let us know if you need more information. If a response worked, kindly mark it as correct for posterity; alternatively, if you found a solution yourself, we’d appreciate it if you could share it with the community. Thank you!

Kautuk Sahni
user65860Author
April 1, 2025

We still haven't found a solution. The above-mentioned solutions were already tried, but they didn't resolve the issue. We are considering trying something new if any other options exist.

If a solution works for us, we will mark it as correct. Even if we find a solution ourselves, we will post it here.