Error reporting information
feign MultipartException: Current request is not a multipart request
On the premise of introducing and configuring openfeign
1. Create FeignMultipartSupportConfig.class configuration file
Just copy and paste it directly
import feign.codec.Encoder;
import feign.form.spring.SpringFormEncoder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Scope;
@Configuration
public class FeignMultipartSupportConfig {
@Bean
@Primary
@Scope("prototype")
public Encoder multipartFormEncoder() {
return new SpringFormEncoder();
}
@Bean
public feign.Logger.Level multipartLoggerLevel() {
return feign.Logger.Level.FULL;
}
}
2. Modify postmapping
-
- 1. MultipartFile type parameters use @RequestPart annotation, string parameters use annotation @RequestParam
-
- 2. Add consumes = MediaType.MULTIPART_FORM_DATA_VALUE
@FeignClient(value = "mk-other", fallback = MkOtherFeignFallBack.class)
public interface MkOtherFeign {
@PostMapping(value = "/file/pic/upload",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseResult picUpload(@RequestPart("file") MultipartFile file);
}
Reference link
Read More:
- [Solved] Upload Files Error: Request processing failed;nested exception is org.springframework.web.multipart.MultipartExcepti
- JAVA: How to Use Multipartfile to upload Files
- [Solved] MultipartException: Failed to parse multipart servlet request; nested exception is java.lang.Runtime
- [Solved] Spring upload file Error: Multipartfile Transferto() reported an error FileNotFoundException
- After asynchronous file import and springboot multipartfile upload, the @async asynchronous processing reports an error: nosuchfileexception
- [Solved] “status“:405,“error“ Request method ‘POST‘ not supported“
- Springboot Files Upload Limit Error: The field file exceeds its maximum permitted size of 1048576 bytes
- Request processing failed; nested exception is java.lang.NullPointerException or UnsatisfiedDependencyE
- Multipartfiletofileutils (multipartfile to file)
- JAVA: How to Use Minio to upload pictures
- How to Solve Springboot Upload Files Error: The field XXX exceeds its maximum permitted size of 1048576 bytes
- Asynchronous processing of HTTP request by Java_ Method 2: through deferredresult
- Asynchronous processing of HTTP request by Java_ Method 1: through callable
- Rancher application service error: request entity too large
- [Solved] Java.lang.IllegalStateException: getReader() has already been called for this request
- [Solved] Failed to bind properties under ‘spring.servlet.multipart.file-size-threshold‘ to
- OpenFeignClient Use Object to Receive text/plain Type Return Error
- [Solved] Pycharm Failed to Upload: Upload to *** failed. Could not list the contents of folder “sftp
- SpringBoot :Error parsing HTTP request header [How to Solve]
- How to Solve “413 request entity too large” Error