All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.main.java.com.vincomobile.fw.basic.tools.ExtendedMultipartResolver Maven / Gradle / Ivy

There is a newer version: 5.1.0-RELEASE
Show newest version
package com.vincomobile.fw.basic.tools;

import org.springframework.web.multipart.commons.CommonsMultipartResolver;

import javax.servlet.http.HttpServletRequest;

public class ExtendedMultipartResolver  extends CommonsMultipartResolver {
    /**
     * Checks if multipart is supported for the request.
     * Only supports multipart for POST and PUT methods
     *
     * @param request Request being analyzed
     * @return True if multipart is supported
     */
    @Override
    public boolean isMultipart(HttpServletRequest request) {
        if(request!=null) {
            String httpMethod = request.getMethod().toLowerCase();
            boolean validMethod = "put".equals(httpMethod) || "post".equals(httpMethod);
            String contentType = request.getContentType();
            return (contentType != null && contentType.toLowerCase().startsWith("multipart") && validMethod);
        }else {
            return false;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy