Examples of DiskFileUpload


Examples of org.apache.commons.fileupload.DiskFileUpload

        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

Examples of org.apache.commons.fileupload.DiskFileUpload

    String retVal = "0";
    String fileUrl = "";
    String errorMessage = "";

    DiskFileUpload upload = new DiskFileUpload();
        upload.setHeaderEncoding("UTF-8");
    try {
      List<FileItem> items = upload.parseRequest(request);
      // We expect first item being 'NewFile'
      FileItem uplFile = items.get(0);
            String fileNameLong = uplFile.getName().replace('\\', '/');
      String[] pathParts = fileNameLong.split("/");
      String fileName = pathParts[pathParts.length - 1];
View Full Code Here

Examples of org.apache.commons.fileupload.DiskFileUpload

    public HttpServletRequest decode(HttpServletRequest request)
    {
        _encoding = request.getCharacterEncoding();

        DiskFileUpload upload = createUpload(request);

        try
        {
            List fileItems = upload
                    .parseRequest(request, _thresholdSize, _maxSize, _repositoryPath);

            processFileItems(fileItems);
        }
        catch (FileUploadException ex)
View Full Code Here

Examples of org.apache.commons.fileupload.DiskFileUpload

        }
    }

    protected DiskFileUpload createUpload(HttpServletRequest request)
    {
        DiskFileUpload upload = new DiskFileUpload();

        if (_encoding != null)
            upload.setHeaderEncoding(_encoding);

        return upload;
    }
View Full Code Here

Examples of org.apache.commons.fileupload.DiskFileUpload

        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",
View Full Code Here

Examples of org.apache.commons.fileupload.DiskFileUpload

      this.empty = empty;
    }

   
    protected DiskFileUpload newFileUpload() {
      return new DiskFileUpload() {
       
        public List parseRequest(HttpServletRequest request) {
          if (request instanceof MultipartHttpServletRequest) {
            throw new IllegalStateException(
                "Already a multipart request");
View Full Code Here

Examples of org.apache.commons.fileupload.DiskFileUpload

        // 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();
        // Set the maximum size before a FileUploadException will be thrown.
        upload.setSizeMax((int) 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

Examples of org.apache.commons.fileupload.DiskFileUpload

        response.setContentType("text/html; charset=" + 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 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

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(maxSize);
      fileUpload.setRepositoryPath(repositoryPath);
      List itemList;
      try {
        itemList = fileUpload.parseRequest(request);
      } catch (FileUploadException e) {
        //LOG.error(e);
        throw new FacesException(e);
      }
      if (LOG.isDebugEnabled()) {
View Full Code Here

Examples of org.apache.commons.fileupload.DiskFileUpload

        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;
        File appBaseDir = 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
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.