org.springframework.web.multipart.support.StandardServletMultipartResolver Java Examples

The following examples show how to use org.springframework.web.multipart.support.StandardServletMultipartResolver. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FastDepFileServlet.java    From fastdep with Apache License 2.0 6 votes vote down vote up
/**
 * Fast dep file service
 *
 * @param request  HttpServletRequest
 * @param response HttpServletResponse
 * @throws IOException
 */
@Override
protected void service(HttpServletRequest request,
                       HttpServletResponse response) throws IOException {
    String requestUri = request.getRequestURI();
    FileStorageUtil fileStorageUtil = new FileStorageUtil(this.fastDepFileProperties);
    String downloadUrl = this.fastDepFileProperties.getDownloadUrl();
    if (this.fastDepFileProperties.getUploadUrl().equals(requestUri)) {
        // HttpServletRequest to MultipartHttpServletRequest
        StandardServletMultipartResolver resolver = new StandardServletMultipartResolver();
        MultipartHttpServletRequest multipartRequest = resolver.resolveMultipart(request);
        MultipartFile files = multipartRequest.getFile(this.fastDepFileProperties.getFieldName());
        FileResponse fileResponse = fileStorageUtil.uploadFile(files);
        response.setContentType("text/json;charset=UTF-8");
        response.setCharacterEncoding("UTF-8");
        PrintWriter out = response.getWriter();
        ObjectMapper mapper = new ObjectMapper();
        String result = mapper.writeValueAsString(fileResponse);
        out.println(result);
        out.flush();
        out.close();
    } else if (requestUri.startsWith(downloadUrl)) {
        // download file
        fileStorageUtil.downloadFile(requestUri.substring(downloadUrl.length() + 1), request, response);
    }
}
 
Example #2
Source File: MultipartConfig.java    From api-layer with Eclipse Public License 2.0 6 votes vote down vote up
@Bean
public MultipartResolver multipartResolver() {
    return new StandardServletMultipartResolver() {
        @Override
        public boolean isMultipart(HttpServletRequest request) {
            String method = request.getMethod().toLowerCase();
            if (!Arrays.asList("put", "post").contains(method)) {
                return false;
            }
            String contentType = request.getContentType();
            return (contentType != null && contentType.toLowerCase().startsWith("multipart/"));
        }
    };
}
 
Example #3
Source File: RequestPartIntegrationTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Bean
public MultipartResolver multipartResolver() {
	return new StandardServletMultipartResolver();
}
 
Example #4
Source File: RequestPartIntegrationTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Bean
public MultipartResolver multipartResolver() {
	return new StandardServletMultipartResolver();
}
 
Example #5
Source File: WebConfig.java    From yfs with Apache License 2.0 4 votes vote down vote up
@Bean
public StandardServletMultipartResolver getStandardServletMultipartResolver() {
    return new StandardServletMultipartResolver();
}
 
Example #6
Source File: WebConfig.java    From pizzeria with MIT License 4 votes vote down vote up
@Bean
public MultipartResolver multipartResolver() throws IOException {
    return new StandardServletMultipartResolver();
}
 
Example #7
Source File: RequestPartIntegrationTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Bean
public MultipartResolver multipartResolver() {
	return new StandardServletMultipartResolver();
}
 
Example #8
Source File: WebConfiguration.java    From java-platform with Apache License 2.0 4 votes vote down vote up
@Bean
public MultipartResolver multipartResolver() {
	StandardServletMultipartResolver resolver = new StandardServletMultipartResolver();
	resolver.setResolveLazily(true);
	return resolver;
}
 
Example #9
Source File: MvcConfiguration.java    From EasyEE with MIT License 4 votes vote down vote up
@Bean
public StandardServletMultipartResolver multipartResolver() {
	StandardServletMultipartResolver ssmr = new StandardServletMultipartResolver();
	return ssmr;
}
 
Example #10
Source File: MvcConfiguration.java    From EasyEE with MIT License 4 votes vote down vote up
@Bean
public StandardServletMultipartResolver multipartResolver() {
	StandardServletMultipartResolver ssmr = new StandardServletMultipartResolver();
	return ssmr;
}
 
Example #11
Source File: WebMvcConfig.java    From bearchoke with Apache License 2.0 4 votes vote down vote up
@Bean(name = "multipartResolver")
public StandardServletMultipartResolver multipartResolver() {
    return new StandardServletMultipartResolver();
}
 
Example #12
Source File: MolgenisWebAppConfig.java    From molgenis with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Bean
public MultipartResolver multipartResolver() {
  return new StandardServletMultipartResolver();
}
 
Example #13
Source File: WebMvcConfiguration.java    From bonita-ui-designer with GNU General Public License v2.0 2 votes vote down vote up
/**
 * To use multipart (based on Servlet 3.0) we need to mark the DispatcherServlet with a {@link javax.servlet.MultipartConfigElement} in programmatic Servlet
 * registration. Configuration settings such as maximum sizes or storage locations need to be applied at that Servlet registration level as Servlet 3.0 does
 * not allow for those settings to be done from the MultipartResolver.
 */
@Bean
public StandardServletMultipartResolver multipartResolver() {
    return new StandardServletMultipartResolver();
}