Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

file upload (restrict the upload file types to PDF only) using cq xtypes/widgets

Avatar

Level 4

Hello All,

I need to write a component that does **file upload (restrict the upload file types to PDF only).**

I have seen CQ has its own dialogs to upload files, but I am not sure, whether I could resuse them.

Please let me know, if I could use out of the box xtypes "smartfile",
"fileuploadfield", "html5fileuploadfield", or "uploaddialogbutton"
with restriction to PDF files.
 
OR  Do I need to write custom component extending one of the xtypes?

I appreciate all the help.

Thank you,
Sri

1 Accepted Solution

Avatar

Correct answer by
Administrator

Hi

Extending to what Scott has mentioned in reply,

You can create a custom uploading component, there you can write a logic to handling a particular type of extension that you would love to upload.

Some facts about PDF, 

1. If you open PDF file in text pad or notepad, it will always start with "%PDF-<version>", so even if you don't want to check mine type or something, just read a line of file, and check if it is of "%PDF-<version>".

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

I hope this would act as some help to you.

 

Thanks and Regards

Kautuk Sahni



Kautuk Sahni

View solution in original post

4 Replies

Avatar

Level 10

you can use ddAccept property. define the MIME type of file which you want to allowed

Documentation

Avatar

Level 4

edubey wrote...

you can use ddAccept property. define the MIME type of file which you want to allowed

Documentation

 

Thank you. ddAccept only works for drag and drop, for upload "mimeType" property works.

Either way, I could not use these OOTB components,as I need to have server side processing to store the files at a specific content dam location.

Avatar

Correct answer by
Administrator

Hi

Extending to what Scott has mentioned in reply,

You can create a custom uploading component, there you can write a logic to handling a particular type of extension that you would love to upload.

Some facts about PDF, 

1. If you open PDF file in text pad or notepad, it will always start with "%PDF-<version>", so even if you don't want to check mine type or something, just read a line of file, and check if it is of "%PDF-<version>".

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

I hope this would act as some help to you.

 

Thanks and Regards

Kautuk Sahni



Kautuk Sahni