zuul网关上传文件

zuul网关上传文件

在zuul网关工程加入实现上传功能的逻辑:

@RestController
public class UploadController {


    @PostMapping(value = "/upload")
    public String upload(@RequestParam(value = "file", required = true) MultipartFile file)
    				 throws IOException {
        byte[] bytes = file.getBytes();
        File saveFile = new File(file.getOriginalFilename());
        FileCopyUtils.copy(bytes, saveFile);
        return saveFile.getAbsolutePath();
    }
}
配置application.yml
spring:
  application:
    name: rpc-zuul
  servlet:
    multipart:
      enabled: true
      max-file-size: 10000000   # 最大单个文件大小
      file-size-threshold: 1000 # 文件写入磁盘的阈值,当上传文件达到 1M 事开始写入磁盘
      location: /               # 上传文件的临时位置

上传访问地址:http://localhost:2001/upload

上传成功,但是中文乱码!!!

中文乱码解决方案

网上说在原有的上传访问路径上前加/zuul,即变成访问http://localhost/zuul/upload

可是为毛我没有成功,日志还报错: No route found for uri: /zuul/upload

上传大文件

Uploading Files through Zuul

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值