Expand my Community achievements bar.

SOLVED

AEM 6.3: Upload multiple renditions

Avatar

Level 2

Hello

At the moment the 'Add Rendition' file upload only works for 1 rendition at a time, my client asked me if it is possible to make it work for multiple renditions at a time.

renditions1.png

I found the corresponding node under '/libs/dam/gui/content/assetdetails/jcr:content/actions/fileupload' and set the the multiple property to 'true'

renditions2.png

The fileupload dialog now allows me to select multiple images but In the end it gives an error. If I for example select 2 images, only 1 of them get uploaded, I get a 500 response for the other:

Screen Shot 2017-11-20 at 11.33.23.png

What am I missing, how can I make this work?

1 Accepted Solution

Avatar

Correct answer by
Level 6

Hi jeroend42683933

I just followed overlaying /libs/dam/gui/content/assetdetails/jcr:content/actions/fileupload to /apps/dam/gui/content/assetdetails/jcr:content/actions/fileupload and update multiple property to true. Its allowing me to select multiple but not upload.

After investigation I don;t see any servlet submission when uploading the asset rendition

Looks like sling:resourceType property is granite/ui/components/coral/foundation/form/fileupload

1356166_pastedImage_1.png

This granite widget can upload only one item (rendition). I think you need a custom widget to handle multiple renditions.

Hope this helps

~Manoj

View solution in original post

9 Replies

Avatar

Administrator

I have asked internal expert to have a look at this.



Kautuk Sahni

Avatar

Level 10

I guess the Servlet on the backed is programmed to handle only 1 asset per request. 

Avatar

Level 10

If you want to upload Assets in a batch operation - you can build a custom Sling Servlet that uses the Asset Manager API. Each Asset that is uploaded will have its own renditions as a result of using the Asset Manager API.

"The CQ5 Quickstart and Web Application."

We have a demo tool that does this. It uses a Java client that reads an XML file that describes where the assets are located and posts each file to the Servlet.

Scott's Digital Community: Automating the process of uploading multiple digital assets to the Adobe ...

So if for example have hundreds of files in a folder - this works well

Avatar

Level 2

Where or how can I find the current servlet that handles the 'add rendition' functionality? The weird things is that the post to the rendition endpoint is executed twice (one of those returns a 200 the other one a 500) which makes me think that the servlet is only handling one file at a time but something else is going wrong, I see this in my error.log:

21.11.2017 08:58:16.425 *ERROR* [0:0:0:0:0:0:0:1 [1511251096318] POST /content/dam/1680jpg.jpg/_jcr_content/renditions HTTP/1.1] org.apache.sling.servlets.post.impl.operations.ModifyOperation Exception during response processing.

org.apache.sling.api.resource.PersistenceException: Unable to commit changes to session.

at org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.commit(JcrResourceProvider.java:499)

at org.apache.sling.resourceresolver.impl.providers.stateful.AuthenticatedResourceProvider.commit(AuthenticatedResourceProvider.java:215)

at org.apache.sling.resourceresolver.impl.helper.ResourceResolverControl.commit(ResourceResolverControl.java:421)

at org.apache.sling.resourceresolver.impl.ResourceResolverImpl.commit(ResourceResolverImpl.java:1177)

at org.apache.sling.servlets.post.AbstractPostOperation.run(AbstractPostOperation.java:160)

at org.apache.sling.servlets.post.impl.SlingPostServlet.doPost(SlingPostServlet.java:205)

...

Caused by: javax.jcr.InvalidItemStateException: OakState0001: Unresolved conflicts in /content/dam/1680jpg.jpg/jcr:content/renditions/renditions2.png/jcr:content

at org.apache.jackrabbit.oak.api.CommitFailedException.asRepositoryException(CommitFailedException.java:237)

at org.apache.jackrabbit.oak.api.CommitFailedException.asRepositoryException(CommitFailedException.java:212)

at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.newRepositoryException(SessionDelegate.java:670)

....

Caused by: org.apache.jackrabbit.oak.api.CommitFailedException: OakState0001: Unresolved conflicts in /content/dam/1680jpg.jpg/jcr:content/renditions/renditions2.png/jcr:content

at org.apache.jackrabbit.oak.plugins.commit.ConflictValidator.failOnMergeConflict(ConflictValidator.java:115)

at org.apache.jackrabbit.oak.plugins.commit.ConflictValidator.propertyAdded(ConflictValidator.java:84)

at org.apache.jackrabbit.oak.spi.commit.CompositeEditor.propertyAdded(CompositeEditor.java:83)

at org.apache.jackrabbit.oak.spi.commit.EditorDiff.propertyAdded(EditorDiff.java:82)

at org.apache.jackrabbit.oak.segment.SegmentNodeState.compareProperties(SegmentNodeState.java:617)

What does this tell me?

Avatar

Level 2

Apparently the coral-fileupload element has an async attribute:

<coral-fileupload

class="betty-ActionBar-item coral-Form-field cq-damadmin-admin-actions-rendition-upload-activator coral3-FileUpload"

name="will_be_replaced" multiple="" sizelimit="10485760"

action="/content/dam/jeroen/de_mol.png/_jcr_content/renditions?_charset_=utf-8" async=""

data-foundation-validation="" data-validation="" role="group" style="position: relative;" aria-disabled="false"

aria-invalid="false" aria-readonly="false">

</coral-fileupload>

If I set the attribute to 'false' it still does not work :S

Avatar

Level 10

THis is why you can look at writing a custom tool that can upload assets to AEM via Servlet that uses the AssetManager API. The Coral FileUploader seems to only handle one at a time.

Avatar

Correct answer by
Level 6

Hi jeroend42683933

I just followed overlaying /libs/dam/gui/content/assetdetails/jcr:content/actions/fileupload to /apps/dam/gui/content/assetdetails/jcr:content/actions/fileupload and update multiple property to true. Its allowing me to select multiple but not upload.

After investigation I don;t see any servlet submission when uploading the asset rendition

Looks like sling:resourceType property is granite/ui/components/coral/foundation/form/fileupload

1356166_pastedImage_1.png

This granite widget can upload only one item (rendition). I think you need a custom widget to handle multiple renditions.

Hope this helps

~Manoj