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

com.alogic.remote.xscript.request.ByMultipartForm Maven / Gradle / Ivy

There is a newer version: 1.6.16
Show newest version
package com.alogic.remote.xscript.request;

import com.alogic.remote.Request;
import com.alogic.remote.xscript.RequestHandler;
import com.alogic.xscript.ExecuteWatcher;
import com.alogic.xscript.Logiclet;
import com.alogic.xscript.LogicletContext;
import com.alogic.xscript.doc.XsObject;
import com.anysoft.util.Properties;
import com.anysoft.util.PropertiesConstants;
import org.apache.commons.lang3.StringUtils;

/**
 * 通过multipart表单发送文件
 *
 * @since 1.6.13.6 [20200629 duanyy] 
*/ public class ByMultipartForm extends RequestHandler { protected String $key = "file"; protected String $filename = ""; protected String $content = ""; public ByMultipartForm(String tag, Logiclet p) { super(tag, p); } @Override public void configure(Properties p){ super.configure(p); $key = PropertiesConstants.getRaw(p,"key",$key); $filename = PropertiesConstants.getRaw(p,"filename",$filename); $content = PropertiesConstants.getRaw(p,"content",$content); } @Override protected void onExecute(final Request req, final XsObject root, final XsObject current, final LogicletContext ctx, final ExecuteWatcher watcher) { String key = PropertiesConstants.transform(ctx,$key,"file"); String filename = PropertiesConstants.transform(ctx,$filename,""); String content = PropertiesConstants.transform(ctx,$content,""); if (StringUtils.isNotEmpty(filename) || StringUtils.isNotEmpty(content)){ req.setMultipartBody(key,filename,content); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy