summary
Recently, in order to do a video detection, when using postman to upload a video, the code threw an error:
ERROR 13557 [] [http-nio-5000-exec-8] org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet] Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadException: the request was rejected because no multipart boundary was found] with root cause
org.apache.tomcat.util.http.fileupload.FileUploadException: the request was rejected because no multipart boundary was found
at org.apache.tomcat.util.http.fileupload.impl.FileItemIteratorImpl.init(FileItemIteratorImpl.java:178)
Background
File upload controller of business application layer:
@Resource
private FileService fileService;
@PostMapping(value = "video")
@ApiOperation(value = "Submit video recognition", httpMethod = "POST")
public Result video(@RequestParam("file") MultipartFile file, @LoginUser SysUser user, HttpServletRequest request) {
Result<FileInfo> fileInfoResult = fileService.fileUpload(ArmConstant.BUCKET, file);
}
The file service in the above code is an interface defined based on feignclient
@FeignClient(name = ServiceNameConstants.FILE_SERVICE, fallbackFactory = FileServiceFallbackFactory.class, decode404 = true)
public interface FileService {
@PostMapping(value = "/upload/{bucket}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
Result<FileInfo> fileUpload(@PathVariable("bucket") String bucket, @RequestParam("file") MultipartFile file);
}
The file service needs a supporting service, namely file center
service, whose controller is defined as follows:
@RestController
@Slf4j
public class FileController {
@PostMapping("/upload/{bucket}")
public Result<FileInfo> fileUpload(@PathVariable("bucket") String bucket, @RequestParam("file") MultipartFile file) {
}
}
analysis
Baidu and Google search all talked about how to set up postman, which once made me question the problem of postman, or my use of postman. Online search, we must take their own critical thinking analysis, many articles are blindly copied. Moreover, as a mature automatic interface testing tool, postman will hardly be found by you and me.
But I’m familiar with the use of postman. In fact, there is no problem with postman configuration:
shelve for one night.
It’s really impossible. Global search multipartfile
:
suddenly find something. What’s the difference between @requestpart and @requestparam
Replace @requestparam in three places with @requestpart to solve the problem;
I have to say that feign has a lot of holes. However, we can’t find any information about fileuploadexception: the request was rejected because no multipart boundary was found
in feign GitHub.
Feign’s pit, refer to my another blog fallback factory
Extension
What is the difference between @requestpart and @requestparam
write another article about the difference between @requestparam and @requestpart and feign’s comments
Read More:
- [Solved] the request was rejected because its size (11579386) exceeds the configured maximum (10485760)
- The request was rejected because the URL contained a potentially malicious String “;” [How to Solve]
- Cordova – CordovaError: Promise rejected with non-error: ‘ios-deploy was not found
- [Solved] @webservice Error: org.apache.cxf.common.i18n.UncheckedException: No operation was found with
- [Solved] MSP430F5529 Error initializing emulator:No USB FET was found
- Error: Unable to build IHost No DbContext named ‘PersistedGrantDbContext‘ was found.
- Current request is not a multipart request [How to Solve]
- An error was reported when Maven package was running the packaged jar package: there is no main list attribute in xxx.jar, which can be solved by configuring Maven plugin
- blackduck Error: Request failed authorization [HTTP Error]: XXX, response was 403 Forbidden.
- There was an unexpected error (type=Method Not Allowed, status=405). Request
- [Solved] volatile was removed and now has no effect. Use `with torch.no_grad():` instead.
- [Solved] Instantiation of ‘sdram_model_plus‘ failed. The design unit was not found.
- C# Error: Import “google/protobuf/timestamp.proto“ was not found or had errors. [How to Solve]
- [Solved] Vscode Error: “export ‘default‘ (imported as ‘VueRouter‘) was not found in ‘vue-router‘
- [Solved] Vue3 Error: export ‘createRouter‘ was not found in ‘vue-router‘
- JSP error: The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path
- [Solved] Castle.MicroKernel.ComponentNotFoundException: No component for supporting the service ****** was f
- Swagger-ui.html Open Error: There was an unexpected error (type=Not Found, status=404)
- The imported project “c:\Microsoft.Cpp.Default.props” was not found
- [Solved] A needed class was not found. This could be due to an error in your runpath. Missing class: scala/co