feign client multipart feign调用服务上传图片 报错 the request was rejected because no multipart boundary was

学习spring cloud   ,些了一个图片上传的服务,直接用postman 请求这个服务,是没有问题的,

但是在web层(comsumer层?)用feign去调用这个服务,就报错了,,

the request was rejected because no multipart boundary was found,,,


原文地址: https://github.com/OpenFeign/feign-form

工程中需要依赖这两个东东

<dependencies>
    ...
    <dependency>
        <groupId>io.github.openfeign.formgroupId>
        <artifactId>feign-formartifactId>
        <version>3.2.2version>
    dependency>
    <dependency>
        <groupId>io.github.openfeign.formgroupId>
        <artifactId>feign-form-springartifactId>
        <version>3.2.2version>
    dependency>
    ...
dependencies>

@FeignClient(name = "file-upload-service", configuration = FileUploadServiceClient.MultipartSupportConfig.class)
public interface FileUploadServiceClient extends IFileUploadServiceClient {

    public class MultipartSupportConfig {

        @Autowired
        private ObjectFactory messageConverters;

        @Bean
        public Encoder feignFormEncoder() {
            return new SpringFormEncoder(new SpringEncoder(messageConverters));
        }
    }
}
@FeignClient(name = "file-upload-service", configuration = FileUploadServiceClient.MultipartSupportConfig.class)
public interface FileUploadServiceClient extends IFileUploadServiceClient {

    public class MultipartSupportConfig {

        @Bean
        public Encoder feignFormEncoder() {
            return new SpringFormEncoder();
        }
    }
}

你可能感兴趣的:(feign client multipart feign调用服务上传图片 报错 the request was rejected because no multipart boundary was)