I have seen fair amount of threads regarding bad request errors upon file upload, however unlike for others, I am sure that Spring is not at fault here, as I am able to upload file via curl without an issue: curl -X POST -v http://localhost:8080/rest/datasets/ -T test.xlsx
ExtJS uploader:
{
xtype: 'filefield',
fieldLabel: 'Select file',
name: 'file',
fieldName : 'file',
listeners: {
change: function(filefield, value, eOpts) {
var form = filefield.up('form').getForm();
form.submit({
url: '/rest/datasets',
headers : {
'Accept' : '*/*',
'Content-Type' : 'multipart/form-data'
},
waitMsg: 'Uploading'
});
}
}
}
Spring controller
@RestController
@RequestMapping("rest/datasets")
public class DatasetController {
@RequestMapping(method = RequestMethod.POST)
public String uploadFile(
@RequestParam("file") MultipartFile file) {
...
}
}
I am using ExtJS 6.0.1 and Spring Boot 1.3.3