0
  HttpPost post = new HttpPost(properties.getPropert("system.api.url"));
            post.setHeader("Accept", "application/json");
            MultipartEntity entity = new MultipartEntity(
                    HttpMultipartMode.BROWSER_COMPATIBLE);
            entity.addPart("file", new FileBody(file, event.getMIMEType()));
            post.setEntity(entity);  

This is how I upload the file as a Multipart file to my rest controller. Is there a max file size that can be uploaded or is there any way that I can define a max file size foe this kind of uploading. I use this code in my Vaadin client side.

Sanjaya Liyanage
  • 4,706
  • 9
  • 36
  • 50

1 Answers1

0

Try this in your config:

@Bean
public MultipartResolver multipartResolver() {
    return new StandardServletMultipartResolver();
}

@Bean
MultipartConfigElement multipartConfigElement() {
    MultiPartConfigFactory factory = new MultiPartConfigFactory();
    factory.setMaxFileSize(env.getRequiredProperty("MAX.FILE.SIZE"));
    factory.setMaxRequestSize(env.getRequiredProperty("MAX.FILES.SIZE"));
    factory.setFileSizeThreshold(env.getRequiredProperty("MAX.MEMORY.SIZE"));
    factory.setLocation(env.getRequiredProperty("IMAGE.PROCESSOR.UPLOADTMP"));

    return factory.createMultipartConfig();
}

I assume that env is Spring configuration environment variables. Or just put values instead.

Alexander Arutinyants
  • 1,619
  • 2
  • 23
  • 49