Expand my Community achievements bar.

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

Avatar

Level 1

 

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.

user65860_0-1743352989241.png

 

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

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

7 Replies

Avatar

Level 9

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.

Avatar

Level 1

AssetManager.createOrUpdateAsset method is deprecated in latest SDK @giuseppebag

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

Avatar

Community Advisor

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-67bf34...

Regards

Albin

https://myprofile.albinsblog.com

Avatar

Level 1

hi @Albin_Issac  - 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. 

Avatar

Community Advisor

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-ef7...

 

Correct way is explained here https://experience-aem.blogspot.com/2021/06/aem-cloud-service-sample-java-standalone-program-upload-... 

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. 

Avatar

Administrator

@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

Avatar

Level 1

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.