Feign-Form Encoder-实现基于Spring MultipartFile 和Spring FeignClient 表单文件上传

本文介绍了如何使用Feign-Form Encoder在Spring MultipartFile和FeignClient中进行表单文件上传。首先在pom.xml引入依赖,然后通过配置启用FeignForm Encoder支持,可以实现Spring FeignClient的文件表单提交功能。此外,还提到一个特性,即使用Apache Commons Fileupload处理multipart响应,将数据保存为字节数组。
摘要由CSDN通过智能技术生成

Feign-Form Encoder-实现基于Spring MultipartFile 和Spring FeignClient 表单文件上传

OpenFeign Form Encoder 支持对application/x-www-form-urlencoded and multipart/form-data 格式的表单数据编码。支持基于Spring MultipartFile 和Spring Cloud Netflix @FeignClient框架的表单文件上传。

1、在 pom.xml文件引入如下依赖:

<dependencies>
  <dependency>
    <groupId>io.github.openfeign.form</groupId>
    <artifactId>feign-form</artifactId>
    <version>3.8.0</version>
  </dependency>
  <dependency>
    <groupId>io.github.openfeign.form</groupId>
    <artifactId>feign-form-spring</artifactId>
    <version>3.8.0</version>
  </dependency>
</dependencies>

2、如何使用FeignForm Encoder

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

  public class MultipartSupportConfig {
   

    @Autowired
    private ObjectFactory<HttpMessageConverters> messageConverters;

    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

蓝亦

感谢博主辛勤的付出

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值