0

I am using Vaadin upload web component https://vaadin.com/elements/vaadin-upload to upload a CSV file from front end after uploading csv file using vaadin upload i am getting 500 internal server error the vaadin upload component is

<vaadin-upload id="calibration"
target="/imdex/idp/api/v1/upload"
method="POST"
timeout=15000
on-upload-start="uploadStarted" >
<iron-icon slot="drop-label-icon" icon="description"></iron-icon>
<span slot="drop-label">Drop your calibration file</span>
</vaadin-upload>

I checked in the header multipart/form data is getting appended to the header, I have checked my server side code from postman i able to send csv file through postman to server side, but the same is not happening from UI. Request header Can anyone help me i am unable to figure out ?

The server side code is :

@RestController
@RequestMapping("imdex/idp/api/v1")
public class BlobstoreController {
@Autowired
BlobstoreService objectStoreService;

@RequestMapping(value = "/upload", method = RequestMethod.POST)
 public @ResponseBody String singleSave(@RequestParam("file") MultipartFile 
file) throws Exception {

 System.out.println("in  upload");

  if (file != null) {
 S3Object obj = new S3Object();
  try {
 obj.setKey(file.getOriginalFilename());
 obj.setObjectContent(file.getInputStream());

  objectStoreService.put(obj);

  } catch (Exception e) {

  throw e;
   } finally {
  obj.close();
  }
  }
  return "uploaded successfully";
  }
Intervalia
  • 10,248
  • 2
  • 30
  • 60
triples13
  • 206
  • 4
  • 18
  • A error 500 is a server error. This usually means that your server ode does not properly handle the incomming request. Look in the logs of your tomcat or what ever servlet engine you use – André Schild Oct 03 '17 at 08:08
  • @AndréSchild as mentioned when hitting through postman the server code is hit and i able to get the file, but when i hit it from UI, i hit the api from frontend i get request i not a multipart – triples13 Oct 03 '17 at 09:13
  • propably looks like some wrong headers. It is hard to recognise problem when we dont see backend. Compare headers from postman and from UI and find difference. Or try to search for problem in your backend which means finds some questions about your backend and handling multipart from vaadin-upload ( i guess there might be some questions on stackoverflow) – Kuba Šimonovský Oct 03 '17 at 10:33
  • 2
    @shashank The server log shows what is causing the problem, look at this instead of guessing on the frontend – André Schild Oct 03 '17 at 11:40
  • @AndréSchild updated server side code , i am able to hit it from POSTMAn and ARC and upload the files, but the same if i try to hit from UI, i kept on getting 415 now with unsupported media type – triples13 Oct 03 '17 at 14:48

0 Answers0