Tabnine Logo
MultiPartForm
Code IndexAdd Tabnine to your IDE (free)

How to use
MultiPartForm
in
com.logicbus.backend.message

Best Java code snippets using com.logicbus.backend.message.MultiPartForm (Showing top 5 results out of 315)

origin: anylogic/alogic

/**
 * 处理已上传的文件
 * @param ctx 上下文
 * @param cookies 处理的cookies
 * @param handler 处理器
 */
public void handle(Context ctx,Object cookies,FileItemHandler handler){
  if (fileItems != null && !fileItems.isEmpty()){
    Map<String,Object> result = new HashMap<String,Object>(); // NOSONAR
    
    for (FileItem item:fileItems){
      if (item != null && !item.isFormField()){
        contentLength += item.getSize();
        Map<String,Object> fileResult = new HashMap<String,Object>(); // NOSONAR
        fileResult.put("field", item.getFieldName());
        fileResult.put("name", item.getName());
        fileResult.put("size",item.getSize());
        handler.handle(ctx,cookies,item, fileResult);
        result.put(item.getFieldName(), fileResult);
      }
    }
    
    getRoot().put("files", result);
  }
}
origin: anylogic/alogic

@Override
public void init(Context ctx) {
  if (!(ctx instanceof HttpContext)){
    throw new ServantException("core.e1001",
        "The context's class must be HttpContext when using UploadFiles");
  }
  
  HttpContext httpCtx = (HttpContext)ctx;
  
  ServletFileUpload fileUpload = new ServletFileUpload(getFileItemFactory());
  
  try {
    fileItems = fileUpload.parseRequest(httpCtx.getRequest());
  } catch (FileUploadException e) {
    logger.error(ExceptionUtils.getStackTrace(e));
    throw new ServantException("core.e1015",e.getMessage());
  }
  
  root = new HashMap<String,Object>(); // NOSONAR
}
origin: anylogic/alogic

@Override
public void finish(Context ctx, boolean closeStream) {
  Map<String,Object> theRoot = getRoot();
  JsonTools.setString(theRoot, "code", ctx.getReturnCode());
  JsonTools.setString(theRoot, "reason", ctx.getReason());
    ctx.setResponseContentType(getContentType());
    byte[] bytes = data.getBytes();
    contentLength += bytes.length;
origin: anylogic/alogic

  @Override
  protected void onExecute(XsObject root,XsObject current, LogicletContext ctx, ExecuteWatcher watcher) {
    MultiPartForm msg = ctx.getObject(pid);
    if (msg == null){
      throw new BaseException("core.e1001","It must be in a UploadTogetherServant servant,check your together script.");
    }
    
    List<FileItem> fileItems = msg.getFileItems();
    for (FileItem item:fileItems){
      try {
        ctx.setObject(cid, item);
        ctx.SetValue("$upload-content-type", item.getContentType());
        ctx.SetValue("$upload-field", item.getFieldName());
        ctx.SetValue("$upload-name", item.getName());
        ctx.SetValue("$upload-size", String.valueOf(item.getSize()));
        super.onExecute(root, current, ctx, watcher);
      }finally{
        ctx.removeObject(cid);
      }
    }
  }
}
origin: anylogic/alogic

  @Override
  protected int onJson(Context ctx)  {
    if (script != null){
      MultiPartForm msg = (MultiPartForm) ctx.asMessage(MultiPartForm.class);
      
      LogicletContext logicletContext = new Context.ServantLogicletContext(ctx);
      logicletContext.setObject("$context", ctx);
      logicletContext.SetValue("$service", service);
      logicletContext.setObject("$message", msg);
      try {
        XsObject doc = new JsonObject("root",msg.getRoot());
        script.execute(doc,doc, logicletContext, null);
      }finally{
        logicletContext.removeObject("$context");
        logicletContext.removeObject("$message");
        String keyword = logicletContext.GetValue("$keyword", "");
        if (StringUtils.isNotEmpty(keyword)){
          ctx.setKeyword(keyword);
        }                
      }
    }else{
      ctx.asMessage(MultiPartForm.class);
    }
    return 0;
  }
}
com.logicbus.backend.messageMultiPartForm

Javadoc

MultiPartForm 处理multipart/form-data类型的输入数据,主要用于处理Http上传文件。

Most used methods

  • getRoot
    获取JSON结构的根节点
  • getContentType
  • getFileItemFactory
    获取FileItemFactory
  • getFileItems
    获取文件列表

Popular in Java

  • Creating JSON documents from java classes using gson
  • getContentResolver (Context)
  • getExternalFilesDir (Context)
  • runOnUiThread (Activity)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • ImageIO (javax.imageio)
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now