Spring Framework CommonsMultipartResolver - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework CommonsMultipartResolver class.

This code example shows how to use the following methods:getFileUpload, newFileUpload
		return new DefaultMultipartRequest(request, parsingResult.getMultipartFiles(),  
				parsingResult.getMultipartParameters(), parsingResult.getMultipartParameterContentTypes()); 
	} 
	 
	protected FileUpload prepareFileUpload(String encoding) { 
		FileUpload fileUpload = getFileUpload(); 
		FileUpload actualFileUpload = fileUpload; 
		if (encoding != null && !encoding.equals(fileUpload.getHeaderEncoding())) { 
			actualFileUpload = newFileUpload(new StreamFileItemFactory()); 
			actualFileUpload.setSizeMax(fileUpload.getSizeMax()); 
			actualFileUpload.setHeaderEncoding(encoding); 
		} 
		return actualFileUpload; 
	}	 
} 
6
CodeRank
This code example shows how to use the following methods:setMaxUploadSize
		return new DatabaseConfig(); 
	} 
 
	@Bean(name = "multipartResolver") 
	public CommonsMultipartResolver multipartResolver() {
		CommonsMultipartResolver cmr = new CommonsMultipartResolver();
 
		cmr.setMaxUploadSize(1024 * 1024 * 1024); // 1 Gigabyte...
 
		return cmr;
	} 
 
        @Bean(name = "jsonpCallbackFilter") 
        public static JsonpCallbackFilter jsonpCallback(){ 
            return new JsonpCallbackFilter(); 
        } 
 
	@Bean 
	public PropertyPlaceholderConfigurer properties() {
		String configurationDirectory = System.getProperty(CONFIG_DIR_PROPERTY);
5
CodeRank
This code example shows how to use the following methods:
package org.activiti.rest.service.api; 
 
import javax.servlet.http.HttpServletRequest; 
 
import org.apache.commons.fileupload.servlet.ServletFileUpload; 
import org.springframework.web.multipart.commons.CommonsMultipartResolver; 
 
public class PutAwareCommonsMultipartResolver extends CommonsMultipartResolver { 
 
  private static final String MULTIPART = "multipart/"; 
 
  @Override 
  public boolean isMultipart(HttpServletRequest request) { 
      return request != null && isMultipartContent(request); 
  } 
 
  /** 
   * Utility method that determines whether the request contains multipart 
   * content. 
   *  

5
CodeRank
This code example shows how to use the following methods:
@ComponentScan(basePackageClasses = FileUploadController.class) 
public class MainConfiguration { 
 
    @Bean 
    public CommonsMultipartResolver multipartResolver() { 
        return new CommonsMultipartResolver(); 
    } 
 
} 
5
CodeRank
This code example shows how to use the following methods:
/** 
 * {@link MultipartResolver} to use instead of {@link CommonsMultipartResolver}. 
 *  
 * @author Gotzon Illarramendi 
 */ 
public class HdivCommonsMultipartResolver extends CommonsMultipartResolver { 
 
	@Override 
	public boolean isMultipart(HttpServletRequest request) { 
 
		HdivMultipartException multipartException = (HdivMultipartException) request 
				.getAttribute(IMultipartConfig.FILEUPLOAD_EXCEPTION); 
		if (multipartException != null) { 
			Exception orig = multipartException.getOriginal(); 
			if (orig instanceof MultipartException) { 
				throw (MultipartException) orig; 
			} else { 
				throw new MultipartException("Could not parse multipart servlet request", orig); 
			} 
		} 
5
CodeRank
This code example shows how to use the following methods:setMaxUploadSize
        return factoryBean; 
    } 
     
    @Bean 
    public MultipartResolver getMultipartResolver() { 
        CommonsMultipartResolver resolver = new CommonsMultipartResolver(); 
        resolver.setMaxUploadSize(5 * 1024 * 1024); // 5MB 
         
        return resolver; 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:setMaxUploadSize
This code example shows how to use the following methods:
 * @see ProgressReporter 
 * @see CommonsMultipartResolver 
 * 
 * @author Keerthi Singri 
 */ 
public class CustomMultipartResolverWithProgress extends CommonsMultipartResolver 
{ 
   private static ThreadLocal<ProgressListener> progressListenerLocal = 
      new ThreadLocal<ProgressListener>(); 
 
   private static final Logger _log = LoggerFactory.getLogger(CustomMultipartResolverWithProgress.class); 
 
   @Override 
   public void cleanupMultipart(MultipartHttpServletRequest request) { 
      // Set upload finished flag on ProgressListenerImpl. 
      ProgressListener pListener = progressListenerLocal.get(); 
      if (pListener instanceof ProgressListenerImpl) { 
         ((ProgressListenerImpl)pListener).setFinished(); 
      } 
      super.cleanupMultipart(request); 
4
CodeRank
This code example shows how to use the following methods:
		configurer.enable();
	} 
 
	@Bean 
	public MultipartResolver multipartResolver() {
		return new CommonsMultipartResolver();
	} 
 
	@Bean(destroyMethod="shutdown") 
	@SuppressWarnings("deprecation") 
	public net.sf.ehcache.CacheManager ehCacheManager(Settings settings) throws IOException {
		File cacheDir = new File(settings.getDocumentrDataDir(), DocumentrConstants.CACHE_DIR_NAME);
		FileUtils.forceMkdir(cacheDir);
 
		net.sf.ehcache.CacheManager ehCacheManager = net.sf.ehcache.CacheManager.newInstance(
				new net.sf.ehcache.config.Configuration() 
					.name("Ehcache") //$NON-NLS-1$ 
					.updateCheck(false) 
					.diskStore(new DiskStoreConfiguration() 
							.path(cacheDir.getAbsolutePath())));
4
CodeRank
This code example shows how to use the following methods:
import javax.servlet.http.HttpServletRequest; 
 
import fr.putnami.pwt.core.inject.client.annotation.PostConstruct; 
 
@Controller 
public class FileTransfertMultipartResolver extends CommonsMultipartResolver { 
 
	private static ThreadLocal<FileTransfertProgressListener> tlUploadId = 
		new ThreadLocal<FileTransfertProgressListener>(); 
 
	@Value("${filetransfertcontroller.maxUploadSize}") 
	private long maxUploadSize; 
 
	@Autowired 
	private FileTransfertController fileTransfertController; 
 
	@PostConstruct 
	public void postConstruct() { 
		this.setMaxUploadSize(this.maxUploadSize); 
	} 
4
CodeRank
See Code Examples for Spring Framework CommonsMultipartResolver Methods: