springboot,feign上传超大文件,超时等问题解决方案

1.在yml中配置文件上传大小限制

 

spring.http.multipart.maxFileSize: 200Mb
spring.http.multipart.maxRequestSize: 200Mb

2.controller中添加上传文件接口

 

 

@PostMapping(value = "/uploadImg")
// @HystrixCommand(fallbackMethod = "abc")
   public HsResult uploadImg(@RequestParam("picFile") MultipartFile picFile) {
      return this.mechanismInfoService.uploadImg(picFile);//具体上传逻辑可以自己实现
   }

 

 

上传成功。

---------------------------------------------------------------------------------------

《feign调用上传接口方案》

1.同样配置yml

 

spring.http.multipart.maxFileSize: 200Mb
spring.http.multipart.maxRequestSize: 200Mb

2.编写feignservice

 

@Autowired
private FeignService feignService;
@PostMapping(value = "/up")
public HsResult up(@RequestParam("picFile") MultipartFile picFile) {
    return this.feignService.uploadImg(picFile);
}

 

 

@Component
@FeignClient(value = "map-service")
public interface FeignService {
    @RequestMapping(value = "/mechanism/uploadImg",method = RequestMethod.POST,produces = {MediaType.APPLICATION_JSON_UTF8_VALUE},consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public HsResult uploadImg(@RequestPart("picFile") MultipartFile picFile);

 

如果报超时错误,需要调大hystrix和ribbon的超时时间!

 

MARK:

最近在关注一个手机挖矿项目,叫Bee蜜蜂币。

APP 下载链接: https://bee.com/sc/

推荐码:lei911gang

手机免费挖矿,感兴趣的可以一起加入。

 

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值