Upload assets programatically | Community
Skip to main content
Community Advisor
October 8, 2024

Upload assets programatically

  • October 8, 2024
  • 1 reply
  • 348 views

I am uploading assets programatically to aem cloud using AssetManager createOrReplaceAsset method

image gets uploaded to AEM however it is taking 5-10 minutes to process the image, apply rendition and properties. I see a call to dynamic media server   https://<aem-auther-server>/adobe/dynamicmedia/deliver/dm-aid--0a0c72d9-d7e4-4f8f-80ae-8448bdaeddff/240-f-322662977-sd7x9fwrjheiv8p1ctprlguhoq9w8fzr.jpg?quality=85&preferwebp=true&width=1600    We dont have dynamic media install, why it is getting uploaded. How do I get the image instantaneously, are there any post processing required?

Here is my code

 

 

JackrabbitValueFactory valueFactory = (JackrabbitValueFactory) session.getValueFactory(); // Download the file with buffering InputStream inputStream = downloadFromSignedUrl(signedUrl); BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream); // Detect MIME type and create binary String mimeType = getMimeType(bufferedInputStream); javax.jcr.Binary binary = valueFactory.createBinary(bufferedInputStream); // Use AssetManager to create or update the asset AssetManager assetManager = resolver.adaptTo(AssetManager.class); if (assetManager == null) { throw new IllegalStateException("Unable to adapt to AssetManager."); } // Create or update the asset without blocking rendition generation assetManager.createOrReplaceAsset(targetDamPath, binary, mimeType, false); LOGGER.info("Asset uploaded successfully to path: {}", targetDamPath); isUpload = true; session.save();

 

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

1 reply

arunpatidar
Community Advisor
Community Advisor
October 9, 2024