zoukankan      html  css  js  c++  java
  • Zuul上传文件

    对于1M以内的文件上传,无需任何处理,大文件10M以上需要为上传路径添加/zuul前缀,也可使用zuul.servlet-path自定义前缀
    如果Zuul使用了Ribbon做负载均衡,那么对于超大的文件,需要提升超时设置:hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds:60000
    ribbon:
        ConnectTimeout: 3000
        ReadTimeout: 60000
     
    将服务注册到Eureka Server上,并配置文件上传大小的限制,配置文件添加以下内容:
        server:
            port: 8050
        eureka:
            client:
                serviceUrl:
                    defaultZone: http://localhost:8761/erueka/
                instance:
                    prefer-ip-address: true
        spring:
            application:
                name: microservice-file-upload
            http:
                multipart:
                    max-file-size: 2000Mb    (默认1M)
                    max-request-size: 2500Mb (默认10M)
     
    @ReponseBody
    @Controller
    public class FileUploadController{
        @RequestMapping(value = "/upload", method = RequestMethod.POST)
        public String handleFileUpload(@RequestParam(value = "file", required = true) MultipartFile file) throws IOException{
            byte[] bytes = file.getBytes();
            File fileToSave = new File(file.getOriginalFilename());
            FileCopyUtils.copy(bytes fileToSave);
            return fileToSave.getAbsolutePath();
        }
    }
  • 相关阅读:
    GHOJ 683 小球
    GHOJ 682 图的m着色问题
    GHOJ 681 最佳调度问题
    YBT 最长公共子上升序列
    YBT 数的划分
    Educational Codeforces Round 68 (Rated for Div. 2) C
    马里奥项目中对象直接通讯小结
    Educational Codeforces Round 67 (Rated for Div. 2) C
    19新疆省赛总结
    Codeforces Round #560 div3 (C,D)
  • 原文地址:https://www.cnblogs.com/gqymy/p/11195794.html
Copyright © 2011-2022 走看看