Rest API call with File upload | Community
Skip to main content
Level 5
Oct 14, 2020 10:42 AM UTC
Solved

Rest API call with File upload

Dear Team,

 

We have come across below requirement:

 

1) We have HTML form with few input fields along with File upload option.

2) Once we submit form, It should call POST rest API and pass on all parameters along with file in some way and based on API response, we need to display messages.

 

Do we have any reference or example for this one?

 

Regards,

Arvind

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Manjunath_K
Manjunath_KAccepted solution
Level 7
Oct 14, 2020 10:58 AM UTC

Hi @arvind-1 

Please find below steps to pass file input.

 

Javascript

Pass this file input in rest API ajax request as request parameter.

fileInput : $('#file-input')[0].files[0]

 

Backend Servlet :

RequestParameter uploadedFile = request.getRequestParameter("fileInput");
InputStream inputStream = uploadedFile.getInputStream();

 

3 replies

Level 4
Oct 14, 2020 11:14 AM UTC

Hi @arvind-1 ,

 

Please follow below article to achieve your requirement.

 

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

 

Thanks,

Sandeep.

Translate
Manjunath_K
Manjunath_KAccepted solution
Level 7
Oct 14, 2020 10:58 AM UTC

Hi @arvind-1 

Please find below steps to pass file input.

 

Javascript

Pass this file input in rest API ajax request as request parameter.

fileInput : $('#file-input')[0].files[0]

 

Backend Servlet :

RequestParameter uploadedFile = request.getRequestParameter("fileInput");
InputStream inputStream = uploadedFile.getInputStream();

 

Translate