Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Asset upload workflow. to accept the path of the file and save it in the DAM.

Avatar

Level 4

Hi Team,

I want to create a workflow to accept the file in the frontend page upon clicking the button. the files should be uploaded to the dam.

can anyone help on it (any sample code will be helpful).

 

Thanks in advance.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

I would follow the below steps for the above mentioned requirements -

 

1. I will create a File Upload component with the ability for the user or the author to browse the file.

2. Upon clicking on upload button I will make post request from File Upload component to custom servlet to trigger my workflow. In this servlet I will capture that uploaded file name and construct payload path as mentioned here -

https://aem.redquark.org/2019/12/workflows-in-aem-05-trigger-workflow.html

3. Finally my custom workflow model(process step) will upload the files to the DAM using below approach -

DEBAL_DAS_0-1648706975671.png

 

Please consider one more point if someone try to upload same file then do you want to show any message.

View solution in original post

4 Replies

Avatar

Employee Advisor

Is there any specific reason you want to write workflow here? 

I feel without having workflow you can achieve the same.

You can make post request while uploading the file to custom servlet and that will persist the file in DAM using AssetaManager API.

 

Please review below method to perform upload operation-

DEBAL_DAS_0-1648621184961.png

https://github.com/Adobe-Consulting-Services/acs-aem-tools/blob/master/bundle/src/main/java/com/adob...

 

Hope it will help you.

Avatar

Level 4

Hi @DEBAL_DAS 

My requirement is to create a workflow to upload files to the DAM.

and user should be able to use it from the page.

let's say a component. and it should give the ability for the user or the author to browse the file and upon clicking on the button it should upload the image to the DAM.

 

Thanks.

Avatar

Correct answer by
Employee Advisor

I would follow the below steps for the above mentioned requirements -

 

1. I will create a File Upload component with the ability for the user or the author to browse the file.

2. Upon clicking on upload button I will make post request from File Upload component to custom servlet to trigger my workflow. In this servlet I will capture that uploaded file name and construct payload path as mentioned here -

https://aem.redquark.org/2019/12/workflows-in-aem-05-trigger-workflow.html

3. Finally my custom workflow model(process step) will upload the files to the DAM using below approach -

DEBAL_DAS_0-1648706975671.png

 

Please consider one more point if someone try to upload same file then do you want to show any message.

Avatar

Level 4

Hi @DEBAL_DAS 

Thank you so much for your answer.

will definitely give a try.