Expand my Community achievements bar.

SOLVED

Upload multiple pdf files from local machine and store files in DAM.

Avatar

Level 2

I am working on one of the requirement where user will upload the pdf files from the local machine. PDF will get store in AEM DAM. Then PDF name will get display on the page.
I have added the multifield in my component and I am using "cq/gui/components/authoring/dialog/fileupload" to browse the PDF files from the local machine and this is working fine but PDF file's binary is not getting stored in the jcr:data so I am not able to store the PDF in DAM. 
When item0,item1 will get create at the node level that time PDF binary should get store in respective node.

Is my approach correct or we can achieve this  without multifield? I need suggestion to work on this usecase.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @Anamika_13 ,

 

Is there a reason as to why these PDFs can't be uploaded directly in DAM asset and why through a component multifield?

Please refer to below page to upload PDFs in AEM Assets

https://experienceleague.adobe.com/docs/experience-manager-65/assets/managing/manage-assets.html?lan...

 

Now, once you have your PDFs in assets, you can create a component to add this pdf on your page

This component's dialog can have following fields

<pdfPath
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/pathbrowser"
fieldLabel="PDF Path"
name="./filePath"
rootPath="/content/dam/"/>
<pdfLabel
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldLabel="PDF Label"
name="./fileLabel"/>
 
Create a Sling Model for this component and display like this on the page
<li><b>${'PDF Path' @ i18n}:</b> <a href="${model.filePath}">${model.fileLabel}</a></li>
Hope this helps!!
Thanks,
Chitra

View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

Hi @Anamika_13 ,

 

Is there a reason as to why these PDFs can't be uploaded directly in DAM asset and why through a component multifield?

Please refer to below page to upload PDFs in AEM Assets

https://experienceleague.adobe.com/docs/experience-manager-65/assets/managing/manage-assets.html?lan...

 

Now, once you have your PDFs in assets, you can create a component to add this pdf on your page

This component's dialog can have following fields

<pdfPath
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/pathbrowser"
fieldLabel="PDF Path"
name="./filePath"
rootPath="/content/dam/"/>
<pdfLabel
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldLabel="PDF Label"
name="./fileLabel"/>
 
Create a Sling Model for this component and display like this on the page
<li><b>${'PDF Path' @ i18n}:</b> <a href="${model.filePath}">${model.fileLabel}</a></li>
Hope this helps!!
Thanks,
Chitra

Avatar

Level 2

End user will not have the access for the DAM. They can just author the page but can not upload the asset in DAM. This is part of requirement that is why I am facing issues. If user will directly upload the pdf file in DAM then I can read the path.

Avatar

Level 7

Your approach is wrong. Why over engineer when AEM provides your the capability to upload/process the assets(images/pdfs).

 

-Bilal

Avatar

Community Advisor

Hi @bilal_ahmad ,

 

This is the standard approach, when you want to refer a pdf on the page.

 However, the requirements mentioned by @Anamika_13 is different and can't be fulfilled with above solution, if the authors will not have access to Assets.