Package org.apache.commons.fileupload

Examples of org.apache.commons.fileupload.DiskFileUpload


      LOG.error(errorText);
      throw new FacesException(errorText);
    } else {
      parameters = new HashMap();
      fileItems = new HashMap();
      DiskFileUpload fileUpload = new DiskFileUpload();
      fileUpload.setSizeMax(1024 * 1024);
      fileUpload.setRepositoryPath(System.getProperty("java.io.tmpdir"));
      // TODO: make sizeMax and repositoryPath configurable
      List itemList;
      try {
        itemList = fileUpload.parseRequest(request);
      } catch (FileUploadException e) {
        LOG.error(e);
        throw new FacesException(e);
      }
      if (LOG.isDebugEnabled()) {
View Full Code Here


        response.setContentType("text/html; charset=" + Constants.CHARSET);

        String message = "";

        // Create a new file upload handler
        DiskFileUpload upload = new DiskFileUpload();

        // Get the tempdir
        File tempdir = (File) getServletContext().getAttribute
            ("javax.servlet.context.tempdir");
        // Set upload parameters
        upload.setSizeMax(-1);
        upload.setRepositoryPath(tempdir.getCanonicalPath());
   
        // Parse the request
        String basename = null;
        String war = null;
        FileItem warUpload = null;
        try {
            List items = upload.parseRequest(request);
       
            // Process the uploaded fields
            Iterator iter = items.iterator();
            while (iter.hasNext()) {
                FileItem item = (FileItem) iter.next();
View Full Code Here

        File tempDir = null;
        File tempFile = null;

        try
        {
            DiskFileUpload upload = new DiskFileUpload();
            tempDir = File.createTempFile("upload", null);
            tempDir.deleteOnExit();
            tempDir.delete();
            tempDir.mkdirs();
            tempDir.deleteOnExit();
            List items = upload.parseRequest(request,0,-1L,tempDir.getAbsolutePath());
            Iterator iter = items.iterator();
            while ( iter.hasNext() )
            {
                FileItem item = (FileItem)iter.next();
                if (!item.isFormField())
View Full Code Here

        File tempDir = null;
        File tempFile = null;

        try
        {
            DiskFileUpload upload = new DiskFileUpload();
            tempDir = File.createTempFile("upload", null);
            tempDir.deleteOnExit();
            tempDir.delete();
            tempDir.mkdirs();
            tempDir.deleteOnExit();
            List items = upload.parseRequest(request,0,-1L,tempDir.getAbsolutePath());
            Iterator iter = items.iterator();
            while ( iter.hasNext() )
            {
                FileItem item = (FileItem)iter.next();
                if (!item.isFormField())
View Full Code Here

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

        //String idFieldValue = null;
        DiskFileUpload fu = new DiskFileUpload();
        List lst = null;
        Locale locale = UtilHttp.getLocale(request);

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

            LocalDispatcher dispatcher = (LocalDispatcher)request.getAttribute("dispatcher");
            GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
            HttpSession session = request.getSession();
            GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");

            DiskFileUpload dfu = new DiskFileUpload();
            //if (Debug.infoOn()) Debug.logInfo("[UploadContentAndImage]DiskFileUpload " + dfu, module);
            java.util.List lst = null;
            try {
                lst = dfu.parseRequest(request);
            } catch (FileUploadException e4) {
                request.setAttribute("_ERROR_MESSAGE_", e4.getMessage());
                Debug.logError("[UploadContentAndImage.uploadContentAndImage] " + e4.getMessage(), module);
                return "error";
            }
View Full Code Here

      
        try {
            HttpSession session = request.getSession();
            GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");

            DiskFileUpload dfu = new DiskFileUpload();
            //if (Debug.infoOn()) Debug.logInfo("[UploadContentAndImage]DiskFileUpload " + dfu, module);
            java.util.List lst = null;
            try {
                lst = dfu.parseRequest(request);
            } catch (FileUploadException e4) {
                request.setAttribute("_ERROR_MESSAGE_", e4.getMessage());
                Debug.logError("[UploadContentAndImage.uploadContentAndImage] " + e4.getMessage(), module);
                return "error";
            }
View Full Code Here

        String encoding = request.getCharacterEncoding();
        // check for multipart content types which may have uploaded items
        boolean isMultiPart = FileUpload.isMultipartContent(request);
        Map multiPartMap = new HashMap();
        if (isMultiPart) {
            DiskFileUpload upload = new DiskFileUpload();
            if (encoding != null) {
                upload.setHeaderEncoding(encoding);
            }
            upload.setSizeMax(maxUploadSize);

            List uploadedItems = null;
            try {
                uploadedItems = upload.parseRequest(request);
            } catch (FileUploadException e) {
                throw new EventHandlerException("Problems reading uploaded data", e);
            }
            if (uploadedItems != null) {
                Iterator i = uploadedItems.iterator();
View Full Code Here

  private void process(HttpServletRequest request) throws Exception {
    // content type multipart
    if (request.getContentType() != null
        && request.getContentType().toLowerCase()
            .indexOf("multipart/form-data") != -1) {
      List l = new DiskFileUpload().parseRequest(request);

      if (itemlistdata == null)
        itemlistdata = new LinkedHashMap();

      // clean previous values
View Full Code Here

            String password = null;
            boolean hasPermission = true;

            ArrayList<String> runIdList = new ArrayList<String>();

            DiskFileUpload fu = new DiskFileUpload();
            // No maximum size
            fu.setSizeMax(-1);
            // maximum size that will be stored in memory
            fu.setSizeThreshold(8192);
            // the location for saving data larger than getSizeThreshold()
            fu.setRepositoryPath(Config.TMP_DIR);

            List fileItems = null;
            try {
                fileItems = fu.parseRequest(request);
            } catch (FileUploadException e) {
                throw new ServletException(e);
            }

            for (Iterator i = fileItems.iterator(); i.hasNext();) {
View Full Code Here

TOP

Related Classes of org.apache.commons.fileupload.DiskFileUpload

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.