Javascript - Upload Excel file - Store in Node - DAM | Community
Skip to main content
MeenakshiP
November 1, 2016
Solved

Javascript - Upload Excel file - Store in Node - DAM

  • November 1, 2016
  • 19 replies
  • 7567 views

Hi All,

I have a question regarding storing excel file in crxde by uploading thru onClick of a new button which I have already added under 'More..' option in DAM.

After clicking on a folder, under 'More..' option, I have added a new button as "Upload File"..

To achieve this, I have added /apps/mytest/clientlibs/dam-gui-admin/js/importFile.js file.

Default functionality in DAM is any selected file to upload will get uploaded to DAM current folder, after clicking on this button...

I am looking for option to:

1. On click of this button 'Upload File' under 'More..' option, user should be able to select the file to upload... (I tried this in javascript, but uploaded file always gets shown in current folder which I do not want).

And

2. The uploaded file should get stored into some node (For example, to store it somewhere under /content/abc/)  in crxde And NOT TO BE SHOWN in current folder in DAM to User...

How to override the default behavior in DAM, so that uploaded file do not gets stored in current folder after uploading, and it gets stored in some Node.

Please note that I am not using any jsp here. I am writing workflow for further business logic processing....Something like:

 var data = {
                ":status":"browser",
                "_charset_":"utf-8",
                model: "/etc/workflow/models/poc/file-import-workflow/jcr:content/model",
                payload: assetPaths,
                payloadType: "JCR_PATH" };

Can you please help?

Thanks.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by kautuk_sahni

Hi 

Any workflow you may follow to upload the file to server, it has to go through back-end code.

In the article :- https://helpx.adobe.com/experience-manager/using/creating-custom-excel-service-experience.html

The excel file is sent to servlet by form submission.

Even if you use AJEX, it will send stream/string/data to servlet, servlet needs to handle it and save it in JCR.

And  "how to upload file from AJEX" see this :- http://blog.teamtreehouse.com/uploading-files-ajax

 

~kautuk

19 replies

kautuk_sahni
Community Manager
Community Manager
November 2, 2016

I would recommend you to please have a look at this Adobe Helpx article.

Link:- https://helpx.adobe.com/experience-manager/using/creating-custom-excel-service-experience.html

// This will help you in Creating a custom Excel Service for Adobe Experience Manager

   In this article, you will upload a Excel file and then persist its data in JCR. The Java Excel API and the JCR API libraries are used in this development article.  

 

Please go through it, i hope this would help you.

 

Thanks and Regards

Kautuk Sahni

Kautuk Sahni
smacdonald2008
November 2, 2016

Kautuk pointed you to correct articke. In this artivle, we read Excel data. However you can use JCR logic to store the file to a JCR node. I will post an article that shows you how to use JCR Api to store a file to a given node.

smacdonald2008
November 2, 2016

See this article to learn how to write an InputStream (which represents the Excel file) to the JCR location: https://helpx.adobe.com/experience-manager/using/post_files.html

June 20, 2023

Hi smacdonald2008,

https://helpx.adobe.com/experience-manager/using/post_files.html

The above link is not working, could you please check and confirm?

  • can u help how to upload a pdf/doc file in the servlet call?
kautuk_sahni
Community Manager
Community Manager
November 3, 2016

Did you try the solution ?

~kautuk

Kautuk Sahni
MeenakshiP
November 4, 2016

Thanks for your quick response.

Yes I am aware about storing the data in JCR and worked on it quite earlier, but it was not thru javascript earlier...

I will try out the javascript part and post here my further findings.

kautuk_sahni
Community Manager
Community Manager
November 4, 2016

Thanks.

Please post the approach that you would follow for communities benefit.

Thanks and Regards

Kautuk Sahni

Kautuk Sahni
smacdonald2008
November 4, 2016

When uploading to AEM - typically you upload to a servlet. You can use JavaScript to perform an AJAX request - but you need to send the file to a servlet. 

kautuk_sahni
Community Manager
kautuk_sahniCommunity ManagerAccepted solution
Community Manager
November 7, 2016

Hi 

Any workflow you may follow to upload the file to server, it has to go through back-end code.

In the article :- https://helpx.adobe.com/experience-manager/using/creating-custom-excel-service-experience.html

The excel file is sent to servlet by form submission.

Even if you use AJEX, it will send stream/string/data to servlet, servlet needs to handle it and save it in JCR.

And  "how to upload file from AJEX" see this :- http://blog.teamtreehouse.com/uploading-files-ajax

 

~kautuk

Kautuk Sahni
MeenakshiP
November 7, 2016

In all these examples, Jsp is used. I do not have any jsp. I have only JS file which I created as: fileUploadTest.js under: /apps/abc/clientlibs/dam-gui-admin/js

Currently I have been calling workflow directly from JS, I think I need to write servlet and from that servlet, I will need to call workflow..

kautuk_sahni
Community Manager
Community Manager
November 8, 2016

MeenakshiP wrote...

I think I need to write servlet and from that servlet, I will need to call workflow..

 

You are right.

~kautuk

Kautuk Sahni