Multipart file upload - maxFileSize exceeded
Asked Answered
B

0

0

I try to upload a file with a size greater than 128kb but I always get (Grails 4)

org.apache.tomcat.util.http.fileupload.impl.SizeLimitExceededException: the request was rejected because its size (1474589) exceeds the configured maximum (128000)

I already tried:

my application.yml:

controllers:
    defaultScope: singleton
    upload:
        maxFileSize: 26214400
        maxRequestSize: 26214400‬

My CustomMultipartResolver:

class CustomMultipartResolver extends StandardServletMultipartResolver {

    static final String FILE_SIZE_EXCEEDED_ERROR = "fileSizeExceeded";

    @Override
    MultipartHttpServletRequest resolveMultipart(HttpServletRequest request) throws MultipartException {
        try {
            return super.resolveMultipart(request);
        } catch (MultipartException  e) {
            log.error(e.message)
            request.setAttribute(FILE_SIZE_EXCEEDED_ERROR, true);
            return new DefaultMultipartHttpServletRequest(request, new LinkedMultiValueMap<String, MultipartFile>(), new LinkedHashMap<String, String[]>(), new LinkedHashMap<String, String>());
        }
    }
}
Baer answered 19/5, 2020 at 13:23 Comment(2)
Does this answer your question? Grails3 file upload maxFileSize limitUndamped
@Undamped it works with maxFileSize and maxRequestSize: but if i also want to use my CustomMultipartResolver it doesn't work...I can't use both. Why is the maxFileSize ignored when I implement my CustomMultipartResolver?Baer

© 2022 - 2024 — McMap. All rights reserved.