Package org.eweb4j.mvc.upload

Examples of org.eweb4j.mvc.upload.Upload


  }

  private void handleUpload() throws Exception{
    ConfigBean cb = (ConfigBean) SingleBeanCache.get(ConfigConstant.CONFIGBEAN_ID);
   
    Upload upload = method.getAnnotation(Upload.class);
    UploadConfigBean ucb = cb.getMvc().getUpload();
    String tmpDir = ucb.getTmp();
    int memoryMax = StringUtil.strToInt(StringUtil.parseFileSize(ucb.getMaxMemorySize())+"");
    long sizeMax = StringUtil.parseFileSize(ucb.getMaxRequestSize());
    //String[] suffix = ucb.getSuffix().split(",");
    if (upload != null){
      if (upload.tmpDir().trim().length() > 0)
        tmpDir = upload.tmpDir();
     
      if (upload.maxMemorySize().trim().length() > 0)
        memoryMax =  StringUtil.strToInt(StringUtil.parseFileSize(upload.maxMemorySize())+"");
     
      if (upload.maxRequestSize().trim().length() > 0)
        sizeMax = StringUtil.parseFileSize(upload.maxRequestSize());
     
      //if (upload.suffix().length > 0)
        //suffix = upload.suffix();
    }
   
    if (tmpDir.trim().length() == 0)
      tmpDir = "${RootPath}"+File.separator+"WEB-INF"+File.separator+"tmp";
   
    tmpDir = tmpDir.replace("${RootPath}", ConfigConstant.ROOT_PATH);
   
    DiskFileItemFactory factory = new DiskFileItemFactory();
    factory.setSizeThreshold(memoryMax);
    factory.setRepository(new File(tmpDir));
   
    ServletFileUpload _upload = new ServletFileUpload(factory);
    _upload.setSizeMax(sizeMax);
    if (upload != null){
      Class<?> clazz = upload.listener();
      if (!void.class.isAssignableFrom(clazz) && ProgressListener.class.isAssignableFrom(clazz))
        _upload.setProgressListener((ProgressListener) clazz.newInstance());
    }
   
    try{
View Full Code Here

TOP

Related Classes of org.eweb4j.mvc.upload.Upload

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.