@Bean
 public MultipartResolver multipartResolver() {
   CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
   multipartResolver.setMaxUploadSize(5 * 1024 * 1024);
   multipartResolver.setMaxInMemorySize(1024 * 1024);
   return multipartResolver;
 }
 @Bean
 public org.springframework.web.multipart.commons.CommonsMultipartResolver multipartResolver() {
   org.springframework.web.multipart.commons.CommonsMultipartResolver multipartResolver =
       new CommonsMultipartResolver();
   multipartResolver.setMaxUploadSize(DEFINE.MAX_UPLOAD_SIZE);
   return multipartResolver;
 }
 @Bean(name = "multipartResolver")
 public CommonsMultipartResolver createMultipartResolver() {
   CommonsMultipartResolver resolver = new CommonsMultipartResolver();
   resolver.setDefaultEncoding("utf-8");
   resolver.setMaxUploadSize(1024 * 1024);
   return resolver;
 }
Exemple #4
0
 @Bean
 public CommonsMultipartResolver commonsMultipartResolver() {
   CommonsMultipartResolver commonsMultipartResolver = new CommonsMultipartResolver();
   commonsMultipartResolver.setDefaultEncoding("UTF-8");
   commonsMultipartResolver.setMaxUploadSize(1024 * 1024 * 256);
   return commonsMultipartResolver;
 }
 // Makes sure you can upload files. (used for the images)
 @Bean(name = "multipartResolver")
 public CommonsMultipartResolver getCommonsMultipartResolver() {
   CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
   multipartResolver.setMaxUploadSize(20971520); // 20MB
   multipartResolver.setMaxInMemorySize(1048576); // 1MB
   return multipartResolver;
 }
 @Bean(name = "multipartResolver")
 public CommonsMultipartResolver createMultipartResolver() {
   CommonsMultipartResolver resolver = new CommonsMultipartResolver();
   resolver.setMaxUploadSizePerFile(2048000); // 2MB	
   resolver.setMaxInMemorySize(2048000);
   resolver.setDefaultEncoding("utf-8");
   return resolver;
 }
 @Bean(name = "multipartResolver")
 public MultipartResolver getMultipartResolver() {
   CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
   multipartResolver.setMaxUploadSize(10240000);
   multipartResolver.setDefaultEncoding("UTF-8");
   multipartResolver.setMaxInMemorySize(8192);
   return multipartResolver;
 }
  @Bean(name = "multipartResolver")
  public CommonsMultipartResolver getResolver() throws IOException {
    CommonsMultipartResolver resolver = new CommonsMultipartResolver();

    // Set the maximum allowed size (in bytes) for each individual file.
    resolver.setMaxUploadSizePerFile(5242880); // 5MB
    resolver.setDefaultEncoding("utf-8");

    // You may also set other available properties.

    return resolver;
  }
 private MultipartResolver getMultipartResolver() {
   if (multipartResolver == null) {
     multipartResolver = new CommonsMultipartResolver();
     ((CommonsMultipartResolver) multipartResolver).setDefaultEncoding("UTF-8");
   }
   return multipartResolver;
 }
  @RequestMapping("/upload/fileImprove")
  public String improveFileUpload(HttpServletRequest request, HttpServletResponse response)
      throws IllegalStateException, IOException {
    CommonsMultipartResolver multipartResolver =
        new CommonsMultipartResolver(request.getSession().getServletContext());
    if (multipartResolver.isMultipart(request)) {
      MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;

      Iterator it = multiRequest.getFileNames();
      while (it.hasNext()) {
        MultipartFile file = multiRequest.getFile((String) it.next());

        if (file != null) {
          String fileName = "demoUpload" + file.getOriginalFilename();
          String path = "D:\\" + fileName;
          File local = new File(path);
          file.transferTo(local);
        }
      }
    }
    return "success";
  }
 @RequestMapping("/testFileUploadDuo")
 public String upload2(HttpServletRequest request, HttpServletResponse response)
     throws IllegalStateException, IOException {
   // 创建一个通用的多部分解析器
   CommonsMultipartResolver multipartResolver =
       new CommonsMultipartResolver(request.getSession().getServletContext());
   // 判断 request 是否有文件上传,即多部分请求
   if (multipartResolver.isMultipart(request)) {
     // 转换成多部分request
     MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
     // 取得request中的所有文件名
     Iterator<String> iter = multiRequest.getFileNames();
     while (iter.hasNext()) {
       // 记录上传过程起始时的时间,用来计算上传时间
       int pre = (int) System.currentTimeMillis();
       // 取得上传文件
       MultipartFile file = multiRequest.getFile(iter.next());
       if (file != null) {
         // 取得当前上传文件的文件名称
         String myFileName = file.getOriginalFilename();
         // 如果名称不为“”,说明该文件存在,否则说明该文件不存在
         if (myFileName.trim() != "") {
           System.out.println("myFileName" + myFileName);
           // 重命名上传后的文件名
           String fileName = "demoUpload/" + file.getOriginalFilename();
           // 定义上传路径
           String path = "E:/" + fileName;
           System.out.println("path=" + path);
           File localFile = new File(path);
           file.transferTo(localFile);
         }
       }
       // 记录上传该文件后的时间
       int finaltime = (int) System.currentTimeMillis();
       System.out.println(finaltime - pre);
     }
   }
   return "/success";
 }
Exemple #12
0
 /** Supports FileUploads. */
 @Bean
 public MultipartResolver multipartResolver() {
   CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
   multipartResolver.setMaxUploadSize(500000);
   return multipartResolver;
 }
Exemple #13
0
 /** 扩展已至此上传进度监控 */
 @Bean
 public MultipartResolver multipartResolver() {
   CommonsMultipartResolver resolver = new FileUploadMultipartResolver();
   resolver.setMaxUploadSize(1000000000);
   return resolver;
 }
 /**
  * Set whether to resolve the multipart request lazily at the time of file or parameter access.
  *
  * <p>Default is "false", resolving the multipart elements immediately, throwing corresponding
  * exceptions at the time of the {@link #resolveMultipart} call. Switch this to "true" for lazy
  * multipart parsing, throwing parse exceptions once the application attempts to obtain multipart
  * files or parameters.
  */
 public void setResolveLazily(boolean resolveLazily) {
   super.setResolveLazily(resolveLazily);
   this.resolveLazily = resolveLazily;
 }
Exemple #15
0
 @Bean
 public CommonsMultipartResolver multipartResolver() {
   CommonsMultipartResolver resolver = new CommonsMultipartResolver();
   resolver.setDefaultEncoding("utf-8");
   return resolver;
 }