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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Triggering asset rendition updates

Avatar

Level 4

We have run into an issue with one of our major integrations that runs every two hours.  The system updates nodes with new images when needed.  Unfortunately, the renditions get out of sync as this update does not trigger rendition updates.  What is the best way to modify this method to trigger the renditions to update?

 

private Node uploadImageToDam(Session session, String imageUrl, Node node, String imagePath) throws URISyntaxException, IOException, RepositoryException { Node imageNode = getNode(session.getRootNode(), imagePath, "dam:Asset"); imageNode.addMixin("mix:versionable"); Node imageContentNode = getNode(imageNode, "jcr:content", "dam:AssetContent"); // Node relatedNode = getNode(imageContentNode, "related", "nt:unstructured"); Node metadataNode = getNode(imageContentNode, "metadata", "nt:unstructured"); metadataNode.addMixin("cq:Taggable"); Node renditionsNode = getNode(imageContentNode, "renditions", "nt:folder"); Node originalNode = getNode(renditionsNode, "original", "nt:file"); Node dataNode = getNode(originalNode, "jcr:content", "nt:resource"); URI uri = new URI(imageUrl); URLConnection conn = uri.toURL().openConnection(); Binary binary = session.getValueFactory().createBinary(new BufferedInputStream(conn.getInputStream())); String mimeType = conn.getContentType(); if (mimeType.contains(";")) { mimeType = mimeType.substring(0, mimeType.indexOf(";")); } dataNode.setProperty("jcr:data", binary); dataNode.setProperty("jcr:mimeType", mimeType); return imageNode; }
1 Accepted Solution

Avatar

Correct answer by
Level 10

WHen you upload  assets to the DAM - use the AssetManager API. By using the AssetManager API - you automatically get renditions. See this article for details on how to use AssetManager API to place uploaded assets into the DAM. 

https://helpx.adobe.com/experience-manager/using/uploading-files-aem1.html

In your example - you are using JCR API - do not use this API to get assets into the Dam. 

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

WHen you upload  assets to the DAM - use the AssetManager API. By using the AssetManager API - you automatically get renditions. See this article for details on how to use AssetManager API to place uploaded assets into the DAM. 

https://helpx.adobe.com/experience-manager/using/uploading-files-aem1.html

In your example - you are using JCR API - do not use this API to get assets into the Dam. 

Avatar

Level 4

Thanks.  We did find that link and tried it quickly, but could not get it to work.  We'll revisit when we have more time and refactor to move it the right method.

Avatar

Level 10

Mark - if you want to have a connect session - i can show you this in action.