Search in sources :

Example 1 with MultipartFile

use of core.framework.web.MultipartFile in project core-ng-project by neowu.

the class RequestParser method parseForm.

private void parseForm(RequestImpl request, HttpServerExchange exchange) {
    FormData formData = exchange.getAttachment(FormDataParser.FORM_DATA);
    if (formData == null)
        return;
    for (String name : formData) {
        FormData.FormValue value = formData.getFirst(name);
        if (value.isFile()) {
            if (!Strings.isEmpty(value.getFileName())) {
                // browser passes empty file name if not choose file in form
                logger.debug("[request:file] {}={}, size={}", name, value.getFileName(), Files.size(value.getPath()));
                request.files.put(name, new MultipartFile(value.getPath(), value.getFileName(), value.getHeaders().getFirst(Headers.CONTENT_TYPE)));
            }
        } else {
            logger.debug("[request:form] {}={}", name, new FieldParam(name, value.getValue()));
            request.formParams.put(name, value.getValue());
        }
    }
}
Also used : FormData(io.undertow.server.handlers.form.FormData) MultipartFile(core.framework.web.MultipartFile) FieldParam(core.framework.impl.log.filter.FieldParam) HttpString(io.undertow.util.HttpString)

Aggregations

FieldParam (core.framework.impl.log.filter.FieldParam)1 MultipartFile (core.framework.web.MultipartFile)1 FormData (io.undertow.server.handlers.form.FormData)1 HttpString (io.undertow.util.HttpString)1