spring cloud feign 上传文件

maven

        
            io.github.openfeign.form
            feign-form
            2.1.0
        
        
            io.github.openfeign.form
            feign-form-spring
            2.1.0
        

feign config

@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;
    }
}

feign client

@FeignClient(name = "xxx",configuration = FeignMultipartSupportConfig.class)
public interface OpenAccountFeignClient {

    @RequestMapping(method = RequestMethod.POST, value = "/xxxxx",produces = {MediaType.APPLICATION_JSON_UTF8_VALUE},consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public ResponseEntity ocrIdCard(@RequestPart(value = "file") MultipartFile file);

}

你可能感兴趣的:(spring cloud feign 上传文件)