[英]Upload Binary file on aws s3 using java Spring
我可以使用下面的表格数据上传文件
但是当我尝试通过选择二进制作为输入来上传文件时,出现以下错误;
{"timestamp":1490680735011,"status":500,"error":"Internal Server Error","exception":"org.springframework.web.multipart.MultipartException","message":"Current request is not a multipart request","path":"/uploadBinary"}
为此,我正在编写代码
@RequestMapping(value = "/uploadBinary", method = RequestMethod.POST)
public ResponseEntity<Object> uploadBinary(
@RequestParam("file") MultipartFile[] multipartFiles) {
try {
System.out.println("starting....");
fileService.upload(multipartFiles);
System.out.println("uploaded successfully ");
} catch (Exception ex) {
System.out.println(ex.getMessage());
return new ResponseEntity<Object>(new String(
"Something Went wrong while uploading data to server"),
HttpStatus.OK);
}
return new ResponseEntity<Object>(new String("uploaded successfully "),
HttpStatus.OK);
}
这对于上载表单数据很好,但是对于二进制选择则不起作用。 我们如何解决这个问题?
检查是否在spring配置文件中添加了CommonsMultipartResolver
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.