Examples of ServletFileUpload


Examples of org.apache.commons.fileupload.servlet.ServletFileUpload

    String comment = null;
    FileItem imageFileFormField = null;
    try
    {
      FileItemFactory factory = new DiskFileItemFactory();
      ServletFileUpload upload = new ServletFileUpload(factory);
      List<?> items = upload.parseRequest(request);
      Iterator<?> iter = items.iterator();
      while(iter.hasNext())
      {
          item = (FileItem)iter.next();
          if(item.getFieldName().equals("file"))
View Full Code Here

Examples of org.apache.commons.fileupload.servlet.ServletFileUpload

            File tmpDir = new File(tempDirectory);
            if (tmpDir.exists() && tmpDir.isDirectory()){
                factory.setRepository(tmpDir);
            }
        }
        ServletFileUpload upload = new ServletFileUpload(factory);
        if (maxFileSize > 0){
            upload.setFileSizeMax(maxFileSize);
        }
       
        Map<String,List<String>> tmpParams = new HashMap<String,List<String>>();
        Map<String,List<MultipartFile>> tmpFiles = new HashMap<String,List<MultipartFile>>();
       
        List<?> items = upload.parseRequest(request);
        for(Object itemObject: items){
            FileItem item = (FileItem)itemObject;
            if (item.isFormField()){
                List<String> list1 = tmpParams.get(item.getFieldName());
                if (list1 == null){
View Full Code Here

Examples of org.apache.commons.fileupload.servlet.ServletFileUpload

      File disk = null;
      FileItem item = null;
      FileItemFactory factory = new DiskFileItemFactory();
      Iterator iter = null;
      List items = null;
      ServletFileUpload upload = new ServletFileUpload( factory );
      ServletOutputStream out = null;
      try{
        items = upload.parseRequest( req );
        iter = items.iterator();
        res.setContentType( " text/xml");
        out = res.getOutputStream();
        out.println( " <response> " );
        while( iter.hasNext() ){
View Full Code Here

Examples of org.apache.commons.fileupload.servlet.ServletFileUpload

 
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    //logger.info("File upload...");
    HttpSession session = request.getSession(true);
    ServletFileUpload upload = new ServletFileUpload();
    upload.setFileSizeMax(MAX_SIZE);
    upload.setHeaderEncoding("UTF-8");
    String message = null;
    Map<String, String> parameters = new HashMap<String, String>();
    List<UploadItem> uploadItems = new ArrayList<UploadItem>();
    try {
      FileItemIterator iter;
      try {
        iter = upload.getItemIterator(request);
        FileItemStream imageFileItem = null;
        String folder = null;
        InputStream stream = null;
        InputStream filestream = null;
        byte[] fileData = null;
View Full Code Here

Examples of org.apache.commons.fileupload.servlet.ServletFileUpload

    ServletOutputStream out = null;

    try {
      HttpRequestHolder.setServletRequest(request);
      FileItemFactory factory = new DiskFileItemFactory();
      ServletFileUpload upload = new ServletFileUpload(factory);

      List<FileItem> items = upload.parseRequest(request);
      response.setContentType("text/xml");
      out = response.getOutputStream();
      for (FileItem item : items) {
        if (!item.isFormField()) {
          out.print("<resource");
View Full Code Here

Examples of org.apache.commons.fileupload.servlet.ServletFileUpload

        // Set factory constraints
        factory.setSizeThreshold(FileUploadConfig.getBufferSize());
        factory.setRepository(new File(FileUploadConfig.getFileTempDir()));
       
        // Create a new file upload handler
        ServletFileUpload upload = new ServletFileUpload(factory);

        // Set overall request size constraint
        upload.setSizeMax(FileUploadConfig.getMaxFileSize());

        List<FileItem> fileItems = null;
        try {
            fileItems = upload.parseRequest(request);
        } catch (FileUploadException fue) {
            LOGGER.severe("File Upload Error", fue); //$NON-NLS-1$
            throw new Frame2Exception("File Upload Exception", fue); //$NON-NLS-1$
        }
View Full Code Here

Examples of org.apache.commons.fileupload.servlet.ServletFileUpload

    // TODO: This method is not used and should be removed. amb
    public static String uploadAndStoreImage(HttpServletRequest request, String idField, String uploadField) {
        //Delegator delegator = (Delegator) request.getAttribute("delegator");

        //String idFieldValue = null;
        ServletFileUpload fu = new ServletFileUpload(new DiskFileItemFactory(10240, FileUtil.getFile("runtime/tmp")));
        List<FileItem> lst = null;
        Locale locale = UtilHttp.getLocale(request);

        try {
            lst = UtilGenerics.checkList(fu.parseRequest(request));
        } catch (FileUploadException e) {
            request.setAttribute("_ERROR_MESSAGE_", e.toString());
            return "error";
        }
View Full Code Here

Examples of org.apache.commons.fileupload.servlet.ServletFileUpload


    private void parseMultiPartPost(ParameterMap parameters) {

        // Create a new file upload handler
        ServletFileUpload upload = new ServletFileUpload();
        upload.setSizeMax(ParameterSupport.maxRequestSize);
        upload.setFileSizeMax(ParameterSupport.maxFileSize);
        upload.setFileItemFactory(new DiskFileItemFactory(ParameterSupport.fileSizeThreshold,
            ParameterSupport.location));

        RequestContext rc = new ServletRequestContext(this.getServletRequest()) {
            @Override
            public String getCharacterEncoding() {
                String enc = super.getCharacterEncoding();
                return (enc != null) ? enc : Util.ENCODING_DIRECT;
            }
        };

        // Parse the request
        List<?> /* FileItem */items = null;
        try {
            items = upload.parseRequest(rc);
        } catch (FileUploadException fue) {
            this.log.error("parseMultiPartPost: Error parsing request", fue);
        }

        if (items != null && items.size() > 0) {
View Full Code Here

Examples of org.apache.commons.fileupload.servlet.ServletFileUpload

        try {
            DiskFileItemFactory factory = new DiskFileItemFactory();
            // try to hold even largish bundles in memory to potentially improve performance
            factory.setSizeThreshold(UPLOAD_IN_MEMORY_SIZE_THRESHOLD);

            ServletFileUpload upload = new ServletFileUpload();
            upload.setFileItemFactory(factory);

            @SuppressWarnings("unchecked")
            List<FileItem> items = upload.parseRequest(req);
            if (items.size() != 1) {
                logAndWriteError("Found " + items.size() + " items to process, but only updating 1 bundle is supported", resp);
                return;
            }
View Full Code Here

Examples of org.apache.commons.fileupload.servlet.ServletFileUpload

        // Create a factory for disk-based file items
        DiskFileItemFactory factory = new DiskFileItemFactory();
        factory.setSizeThreshold(256000);

        // Create a new file upload handler
        ServletFileUpload upload = new ServletFileUpload(factory);
        upload.setSizeMax(-1);

        // Parse the request
        boolean noRedirect = false;
        String bundleLocation = null;
        InputStream bundleStream = null;
        try {
            List /* FileItem */items = upload.parseRequest(req);

            Iterator iter = items.iterator();
            while (iter.hasNext()) {
                FileItem item = (FileItem) iter.next();

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.