0

I've been googling for this issue without any luck.

I have an HTML AngularJS 1.6 view posting to a Spring 4 REST POST service, trying to upload a JSON file.

<form ng-controller="fupController">
        <input type="file" id="file" name="file" ng-files="getTheFiles($files)" />
        <input type="button" ng-click="uploadFiles()" value="Subir archivo" />
    </form>

And the backend:

@RequestMapping(value="/uploadForm", method=RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public @ResponseBody String handleFileUpload(@RequestParam MultipartFile file)
    {
        //MultipartFile file = null;
        logInfo("uploaded file: " + file);

If I change it to @ModelAttribute instead of @RequestParam, the backend gets null in that parameter. If I change it to RequestBody 415 or 403 is thrown.

I'm stuck here. Any help would be very appreciated.

Camilo
  • 439
  • 5
  • 13
  • There is already a helpful SO post [here] http://stackoverflow.com/a/20506037/2903396 – SNP Apr 20 '17 at 18:04
  • Turned out the data I was sending didn't include the parameter name "file". Solved that but now it says "Current request is not a multipart request". A step forward. I'll keep this post posted. – Camilo Apr 20 '17 at 18:52

0 Answers0