Codota Logo
MultiPartForm
Code IndexAdd Codota 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)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
OutputStreamWriter o =
  • Codota IconOutputStream out;new OutputStreamWriter(out)
  • Codota IconOutputStream out;String charsetName;new OutputStreamWriter(out, charsetName)
  • Codota IconHttpURLConnection connection;new OutputStreamWriter(connection.getOutputStream())
  • Smart code suggestions by Codota
}
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

  • Making http requests using okhttp
  • getExternalFilesDir (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getSupportFragmentManager (FragmentActivity)
    Return the FragmentManager for interacting with fragments associated with this activity.
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Vector (java.util)
    The Vector class implements a growable array of objects. Like an array, it contains components that
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now