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

top.jfunc.http.component.apache.DefaultApacheUploadContentCallbackCreator Maven / Gradle / Ivy

package top.jfunc.http.component.apache;

import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.HttpRequest;
import top.jfunc.http.base.ContentCallback;
import top.jfunc.http.base.FormFile;
import top.jfunc.http.component.AbstractUploadContentCallbackCreator;
import top.jfunc.http.request.UploadRequest;
import top.jfunc.http.util.ApacheUtil;
import top.jfunc.common.utils.MultiValueMap;

import java.io.IOException;

/**
 * @author xiongshiyan at 2020/1/7 , contact me with email [email protected] or phone 15208384257
 */
public class DefaultApacheUploadContentCallbackCreator extends AbstractUploadContentCallbackCreator {
    @Override
    protected ContentCallback doCreate(UploadRequest uploadRequest) throws IOException {
        return request -> upload(request, uploadRequest.getFormParams() , uploadRequest.getParamCharset() , uploadRequest.getFormFiles());
    }

    protected void upload(HttpRequest request, MultiValueMap params , String charset , Iterable formFiles) throws IOException{
        if(!(request instanceof HttpEntityEnclosingRequest)){
            return;
        }

        ApacheUtil.upload0((HttpEntityEnclosingRequest)request, params, charset, formFiles);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy