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

cc.shacocloud.mirage.web.bind.support.MultipartFileUploadArgumentResolver Maven / Gradle / Ivy

package cc.shacocloud.mirage.web.bind.support;

import cc.shacocloud.mirage.web.HandleMethodArgumentResolver;
import cc.shacocloud.mirage.web.HttpRequest;
import cc.shacocloud.mirage.web.bind.annotation.FileUpload;
import cc.shacocloud.mirage.web.http.MultipartFileUpload;
import cc.shacocloud.mirage.web.bind.WebDataBinderFactory;
import io.vertx.core.Future;
import org.springframework.core.MethodParameter;

/**
 * 解析文件长传的方法参数
 *
 * @see MultipartFileUpload
 * @see FileUpload
 */
public class MultipartFileUploadArgumentResolver implements HandleMethodArgumentResolver {

    @Override
    public boolean supportsParameter(MethodParameter parameter) {
        return parameter.hasParameterAnnotation(FileUpload.class)
                && MultipartFileUpload.class.isAssignableFrom(parameter.getParameterType());
    }

    @Override
    public Future resolveArgument(HttpRequest request,
                                          MethodParameter parameter,
                                          WebDataBinderFactory binderFactory) {
        return Future.succeededFuture(request.fileUploads());
    }

}