View Javadoc

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17  package org.apache.commons.fileupload;
    18
    19  import java.io.File;
    20  import org.apache.commons.fileupload.disk.DiskFileItemFactory;
    21
    22  /**
    23   * <p>The default {@link org.apache.commons.fileupload.FileItemFactory}
    24   * implementation. This implementation creates
    25   * {@link org.apache.commons.fileupload.FileItem} instances which keep their
    26   * content either in memory, for smaller items, or in a temporary file on disk,
    27   * for larger items. The size threshold, above which content will be stored on
    28   * disk, is configurable, as is the directory in which temporary files will be
    29   * created.</p>
    30   *
    31   * <p>If not otherwise configured, the default configuration values are as
    32   * follows:
    33   * <ul>
    34   *   <li>Size threshold is 10KB.</li>
    35   *   <li>Repository is the system default temp directory, as returned by
    36   *       <code>System.getProperty("java.io.tmpdir")</code>.</li>
    37   * </ul>
    38   * </p>
    39   *
    40   * @author <a href="mailto:martinc@apache.org">Martin Cooper</a>
    41   *
    42   * @version $Id: DefaultFileItemFactory.java 479262 2006-11-26 03:09:24Z niallp $
    43   *
    44   * @deprecated Use <code>DiskFileItemFactory</code> instead.
    45   */
    46  public class DefaultFileItemFactory extends DiskFileItemFactory {
    47
    48      // ----------------------------------------------------------- Constructors
    49
    50
    51      /**
    52       * Constructs an unconfigured instance of this class. The resulting factory
    53       * may be configured by calling the appropriate setter methods.
    54       *
    55       * @deprecated Use <code>DiskFileItemFactory</code> instead.
    56       */
    57      public DefaultFileItemFactory() {
    58          super();
    59      }
    60
    61
    62      /**
    63       * Constructs a preconfigured instance of this class.
    64       *
    65       * @param sizeThreshold The threshold, in bytes, below which items will be
    66       *                      retained in memory and above which they will be
    67       *                      stored as a file.
    68       * @param repository    The data repository, which is the directory in
    69       *                      which files will be created, should the item size
    70       *                      exceed the threshold.
    71       *
    72       * @deprecated Use <code>DiskFileItemFactory</code> instead.
    73       */
    74      public DefaultFileItemFactory(int sizeThreshold, File repository) {
    75          super(sizeThreshold, repository);
    76      }
    77
    78
    79      // --------------------------------------------------------- Public Methods
    80
    81      /**
    82       * Create a new {@link org.apache.commons.fileupload.DefaultFileItem}
    83       * instance from the supplied parameters and the local factory
    84       * configuration.
    85       *
    86       * @param fieldName   The name of the form field.
    87       * @param contentType The content type of the form field.
    88       * @param isFormField <code>true</code> if this is a plain form field;
    89       *                    <code>false</code> otherwise.
    90       * @param fileName    The name of the uploaded file, if any, as supplied
    91       *                    by the browser or other client.
    92       *
    93       * @return The newly created file item.
    94       *
    95       * @deprecated Use <code>DiskFileItemFactory</code> instead.
    96       */
    97      public FileItem createItem(
    98              String fieldName,
    99              String contentType,
    100             boolean isFormField,
    101             String fileName
    102             ) {
    103         return new DefaultFileItem(fieldName, contentType,
    104                 isFormField, fileName, getSizeThreshold(), getRepository());
    105     }
    106
    107 }