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

top.jfunc.http.holderrequest.UploadRequest Maven / Gradle / Ivy

package top.jfunc.http.holderrequest;

import top.jfunc.common.utils.MultiValueMap;
import top.jfunc.http.base.FormFile;
import top.jfunc.http.holder.FormFileHolder;
import top.jfunc.http.holder.ParamHolder;

import java.util.Map;

/**
 * 文件上传请求
 * @author xiongshiyan at 2019/5/18 , contact me with email [email protected] or phone 15208384257
 */
public interface UploadRequest extends HttpRequest, top.jfunc.http.request.UploadRequest {
    /**
     * 接管Form param的处理
     * @return ParamHolder must not null
     */
    ParamHolder formParamHolder();

    /**
     * 获取Form参数
     * @return Form参数
     */
    @Override
    default MultiValueMap getFormParams(){
        return formParamHolder().get();
    }

    /**
     * 设置form参数
     * @param formParams formParams
     * @return this
     */
    @Override
    default UploadRequest setFormParams(Map formParams) {
        formParamHolder().set(formParams);
        return this;
    }

    /**
     * 设置form参数
     * @param formParams formParams
     * @return this
     */
    @Override
    default UploadRequest setFormParams(MultiValueMap formParams) {
        formParamHolder().set(formParams);
        return this;
    }

    /**
     * 新增form参数
     * @param key key
     * @param value value
     * @param values values
     * @return this
     */
    @Override
    default UploadRequest addFormParam(String key, String value, String... values){
        formParamHolder().add(key, value, values);
        return this;
    }

    /**
     * 获取参数编码
     * @return 参数编码
     */
    @Override
    default String getParamCharset(){
        return formParamHolder().getParamCharset();
    }

    /**
     * 提供便捷设置编码的方法
     * @param paramCharset 参数编码
     * @return this
     */
    @Override
    default UploadRequest setParamCharset(String paramCharset){
        formParamHolder().setParamCharset(paramCharset);
        return this;
    }

    /**
     * 上传文件信息
     * @return 上传文件信息
     */
    @Override
    default Iterable getFormFiles(){
        return formFileHolder().getFormFiles();
    }

    /**
     * 新增文件上传信息
     * @param formFiles 上传的文件
     * @return this
     */
    @Override
    default UploadRequest addFormFile(FormFile... formFiles){
        formFileHolder().addFormFile(formFiles);
        return this;
    }
    /**
     * 新增文件上传信息
     * @param formFiles 上传的文件
     * @return this
     */
    @Override
    default UploadRequest addFormFiles(Iterable formFiles){
        formFileHolder().addFormFiles(formFiles);
        return this;
    }

    /**
     * 接管文件上传信息
     * @return FormFileHolder must not be null
     */
    FormFileHolder formFileHolder();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy