我使用Postman(知道across all major browsers)和Swagger UI测试文件上传。而Spring Boot抱怨Required request part 'file' is not present
虽然它实际上已经发送,但它当然是在我的Spring Boot应用程序中提供的。该文件为80 KB。
请帮助摆脱这个错误。
Swagger日志:
POST /some/url
Accept:*/*
Accept-Encoding:gzip, deflate, br
Accept-Language:ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4,la;q=0.2
Connection:keep-alive
Content-Length:143168
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryBxCvTXJ7Xsst0oxO
Host:localhost:8080
X-Requested-With:XMLHttpRequest
------WebKitFormBoundaryBxCvTXJ7Xsst0oxO
Content-Disposition: form-data; name="file"; filename="69426467.jpg"
Content-Type: image/jpeg
------WebKitFormBoundaryBxCvTXJ7Xsst0oxO--
Java控制器:
@RequestMapping(value = "/some/url", method = RequestMethod.POST)
@ResponseBody
public String createPhoto(@RequestParam("file") MultipartFile multipart) {
...