Spring REST MultipartFile file is always null when do upload file

Viewed 10470
@RequestMapping(value = "{fileName:.+}", method = RequestMethod.POST, consumes = { MediaType.MULTIPART_FORM_DATA_VALUE})
public ResponseEntity<ResponseEnvelope<String>> uploadFile(
         @RequestParam("ownerId") Long ownerId, 
         @PathVariable("fileName") String fileName,
         @RequestBody MultipartFile file)
         throws Exception {
    ResponseEnvelope<String> env;
    if(null == certFileContent) {
        env = new ResponseEnvelope<String>("fail");
        return new ResponseEntity<ResponseEnvelope<String>>(env, HttpStatus.OK);
    }
    service.uploadCertificate(ownerId, fileName, certFileContent.getBytes());
    env = new ResponseEnvelope<String>("success");
    return new ResponseEntity<ResponseEnvelope<String>>(env, HttpStatus.OK);
}

Why I always get the file value is null, I've configure the multipart support,see below,

2 Answers
Related