Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one or more
   * contributor license agreements.  See the NOTICE file distributed with
   * this work for additional information regarding copyright ownership.
   * The ASF licenses this file to You under the Apache License, Version 2.0
   * (the "License"); you may not use this file except in compliance with
   * the License.  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package org.apache.commons.fileupload;
 
 import java.io.File;
 import java.util.List;
 import  javax.servlet.http.HttpServletRequest;

High level API for processing file uploads.

This class handles multiple files per single HTML widget, sent using multipart/mixed encoding type, as specified by RFC 1867. Use .parseRequest(HttpServletRequest) to acquire a list of org.apache.commons.fileupload.FileItems associated with a given HTML widget.

Individual parts will be stored in temporary disk storage or in memory, depending on their size, and will be available as org.apache.commons.fileupload.FileItems.

Deprecated:
1.1 Use ServletFileUpload together with DiskFileItemFactory instead.
Version:
$Id: DiskFileUpload.java 1454690 2013-03-09 12:08:48Z simonetripodi $
 
 public class DiskFileUpload
     extends FileUploadBase {
 
     // ----------------------------------------------------------- Data members
 
    
The factory to use to create new form items.
 
 
     // ----------------------------------------------------------- Constructors
 
    
Constructs an instance of this class which uses the default factory to create FileItem instances.

Deprecated:
1.1 Use FileUpload instead.
See also:
DiskFileUpload(DefaultFileItemFactory fileItemFactory)
 
     @Deprecated
     public DiskFileUpload() {
         super();
         this. = new DefaultFileItemFactory();
     }

    
Constructs an instance of this class which uses the supplied factory to create FileItem instances.

Deprecated:
1.1 Use FileUpload instead.
Parameters:
fileItemFactory The file item factory to use.
See also:
DiskFileUpload()
 
     @Deprecated
     public DiskFileUpload(DefaultFileItemFactory fileItemFactory) {
         super();
         this. = fileItemFactory;
     }
 
     // ----------------------------------------------------- Property accessors
 
    
Returns the factory class used when creating file items.

Deprecated:
1.1 Use FileUpload instead.
Returns:
The factory class for new file items.
 
     @Override
     @Deprecated
     public FileItemFactory getFileItemFactory() {
         return ;
     }

    
Sets the factory class to use when creating file items. The factory must be an instance of DefaultFileItemFactory or a subclass thereof, or else a ClassCastException will be thrown.

Deprecated:
1.1 Use FileUpload instead.
Parameters:
factory The factory class for new file items.
    @Override
    @Deprecated
    public void setFileItemFactory(FileItemFactory factory) {
        this. = (DefaultFileItemFactoryfactory;
    }

    
Returns the size threshold beyond which files are written directly to disk.

Deprecated:
1.1 Use DiskFileItemFactory instead.
Returns:
The size threshold, in bytes.
See also:
setSizeThreshold(int)
    @Deprecated
    public int getSizeThreshold() {
        return .getSizeThreshold();
    }

    
Sets the size threshold beyond which files are written directly to disk.

Deprecated:
1.1 Use DiskFileItemFactory instead.
Parameters:
sizeThreshold The size threshold, in bytes.
See also:
getSizeThreshold()
    @Deprecated
    public void setSizeThreshold(int sizeThreshold) {
        .setSizeThreshold(sizeThreshold);
    }

    
Returns the location used to temporarily store files that are larger than the configured size threshold.

Deprecated:
1.1 Use DiskFileItemFactory instead.
Returns:
The path to the temporary file location.
See also:
setRepositoryPath(String)
    @Deprecated
    public String getRepositoryPath() {
        return .getRepository().getPath();
    }

    
Sets the location used to temporarily store files that are larger than the configured size threshold.

Deprecated:
1.1 Use DiskFileItemFactory instead.
Parameters:
repositoryPath The path to the temporary file location.
See also:
getRepositoryPath()
    @Deprecated
    public void setRepositoryPath(String repositoryPath) {
        .setRepository(new File(repositoryPath));
    }
    // --------------------------------------------------------- Public methods

    
Processes an RFC 1867 compliant multipart/form-data stream. If files are stored on disk, the path is given by getRepository().

Deprecated:
1.1 Use ServletFileUpload instead.
Parameters:
req The servlet request to be parsed. Must be non-null.
sizeThreshold The max size in bytes to be stored in memory.
sizeMax The maximum allowed upload size, in bytes.
path The location where the files should be stored.
Returns:
A list of FileItem instances parsed from the request, in the order that they were transmitted.
Throws:
FileUploadException if there are problems reading/parsing the request or storing files.
    @Deprecated
    public List<FileItemparseRequest(HttpServletRequest req,
                                            int sizeThreshold,
                                            long sizeMaxString path)
        throws FileUploadException {
        setSizeThreshold(sizeThreshold);
        setSizeMax(sizeMax);
        setRepositoryPath(path);
        return parseRequest(req);
    }
New to GrepCode? Check out our FAQ X