Package org.apache.commons.fileupload

Examples of org.apache.commons.fileupload.DiskFileUpload


        boolean isMultipart = FileUpload.isMultipartContent(req);
        if (isMultipart) {

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

                List items = upload.parseRequest(req);

                // Process the uploaded items
                Iterator iter = items.iterator();
                while (iter.hasNext()) {
                    FileItem item = (FileItem) iter.next();
View Full Code Here


        Locale locale = UtilHttp.getLocale(request);
       
        HashMap results = new HashMap();
        HashMap formInput = new HashMap();
        results.put("formInput", formInput);
        DiskFileUpload fu = new DiskFileUpload();
        java.util.List lst = null;
        try {
           lst = fu.parseRequest(request);
        } catch (FileUploadException e4) {
            return ServiceUtil.returnError(e4.getMessage());
        }

        if (lst.size() == 0) {
View Full Code Here

        String encoding = request.getCharacterEncoding();

        // DiskFileUpload is not quite threadsafe, so we create a new instance
        // for each request.

        DiskFileUpload upload = new DiskFileUpload();

        List parts = null;

        try
        {
            if (encoding != null)
                upload.setHeaderEncoding(encoding);
            parts = upload.parseRequest(request, _thresholdSize, _maxSize, _repositoryPath);
        }
        catch (FileUploadException ex)
        {
            throw new ApplicationRuntimeException(
                Tapestry.format("DefaultMultipartDecoder.unable-to-decode", ex.getMessage()),
View Full Code Here

        String encoding = request.getCharacterEncoding();

        // DiskFileUpload is not quite threadsafe, so we create a new instance
        // for each request.

        DiskFileUpload upload = new DiskFileUpload();

        List parts = null;

        try
        {
            if (encoding != null)
                upload.setHeaderEncoding(encoding);
            parts = upload.parseRequest(request, _thresholdSize, _maxSize, _repositoryPath);
        }
        catch (FileUploadException ex)
        {
            throw new ApplicationRuntimeException(
                Tapestry.format("DefaultMultipartDecoder.unable-to-decode", ex.getMessage()),
View Full Code Here

      webCtx.setCurrentWorkspace(workspace);

      Node parentFolder = (Node)webCtx.getSession().getItem(currentFolderStr);

      DiskFileUpload upload = new DiskFileUpload();
      List items = upload.parseRequest(request);

      Map fields = new HashMap();

      Iterator iter = items.iterator();
      while (iter.hasNext())
View Full Code Here

   *             if an unrecoverable error occurs.
   */
  public HttpServletRequest handleMultipartRequest(RequestWrapper request, ServletContext servletContext)
      throws HdivMultipartException {

    DiskFileUpload upload = new DiskFileUpload();

    upload.setHeaderEncoding(request.getCharacterEncoding());
    // Set the maximum size before a FileUploadException will be thrown.
    upload.setSizeMax(getSizeMax());
    // Set the maximum size that will be stored in memory.
    upload.setSizeThreshold((int) getSizeThreshold());
    // Set the the location for saving data on disk.
    upload.setRepositoryPath(getRepositoryPath(servletContext));

    List<FileItem> items = null;
    try {
      items = upload.parseRequest(request);

    } catch (DiskFileUpload.SizeLimitExceededException e) {
      if (log.isErrorEnabled()) {
        log.error("Size limit exceeded exception");
      }
View Full Code Here

    } else {
      byte[] data = null;
      try {
        // STEP 1. GATHER UPLOADED ITEMS
        // Create a new file upload handler
        DiskFileUpload upload = new DiskFileUpload();

        // Parse the request
        List<FileItem> items = upload.parseRequest(req);
        Iterator<FileItem> iter = items.iterator();
        while (iter.hasNext()) {
          FileItem item = (FileItem) iter.next();

          if (!item.isFormField()) {
View Full Code Here

      webCtx.setCurrentWorkspace(workspace);

      Node parentFolder = (Node)webCtx.getSession().getItem(currentFolderStr);

      DiskFileUpload upload = new DiskFileUpload();
      List items = upload.parseRequest(request);

      Map fields = new HashMap();

      Iterator iter = items.iterator();
      while (iter.hasNext())
View Full Code Here

        this.thresholdSize = thresholdSize;
        this.repositoryPath = repositoryPath;
    }

    private void parseRequest() {
        fileUpload = new DiskFileUpload();
        fileUpload.setFileItemFactory(new DefaultFileItemFactory());
        fileUpload.setSizeMax(maxSize);

        fileUpload.setSizeThreshold(thresholdSize);
View Full Code Here

        // Get the app config for the current request.
        ModuleConfig ac =
            (ModuleConfig) request.getAttribute(Globals.MODULE_KEY);

        // Create and configure a DIskFileUpload instance.
        DiskFileUpload upload = new DiskFileUpload();

        // The following line is to support an "EncodingFilter"
        // see http://issues.apache.org/bugzilla/show_bug.cgi?id=23255
        upload.setHeaderEncoding(request.getCharacterEncoding());

        // Set the maximum size before a FileUploadException will be thrown.
        upload.setSizeMax(getSizeMax(ac));

        // Set the maximum size that will be stored in memory.
        upload.setSizeThreshold((int) getSizeThreshold(ac));

        // Set the the location for saving data on disk.
        upload.setRepositoryPath(getRepositoryPath(ac));

        // Create the hash tables to be populated.
        elementsText = new Hashtable();
        elementsFile = new Hashtable();
        elementsAll = new Hashtable();

        // Parse the request into file items.
        List items = null;

        try {
            items = upload.parseRequest(request);
        } catch (DiskFileUpload.SizeLimitExceededException e) {
            // Special handling for uploads that are too big.
            request.setAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED,
                Boolean.TRUE);
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.