    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *      http://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017package org.apache.commons.fileupload;
    018
    019/**
    020 * <p>High level API for processing file uploads.</p>
    021 *
    022 * <p>This class handles multiple files per single HTML widget, sent using
    023 * {@code multipart/mixed} encoding type, as specified by
    024 * <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>.  Use {@link
    025 * #parseRequest(RequestContext)} to acquire a list
    026 * of {@link org.apache.commons.fileupload.FileItem FileItems} associated
    027 * with a given HTML widget.</p>
    028 *
    029 * <p>How the data for individual parts is stored is determined by the factory
    030 * used to create them; a given part may be in memory, on disk, or somewhere
    031 * else.</p>
    032 */
    033public class FileUpload
    034    extends FileUploadBase {
    035
    036    /**
    037     * The factory to use to create new form items.
    038     */
    039    private FileItemFactory fileItemFactory;
    040
    041    /**
    042     * Constructs an uninitialized instance of this class.
    043     *
    044     * A factory must be
    045     * configured, using {@code setFileItemFactory()}, before attempting
    046     * to parse requests.
    047     *
    048     * @see #FileUpload(FileItemFactory)
    049     */
    050    public FileUpload() {
    051    }
    052
    053    /**
    054     * Constructs an instance of this class which uses the supplied factory to
    055     * create {@code FileItem} instances.
    056     *
    057     * @see #FileUpload()
    058     * @param fileItemFactory The factory to use for creating file items.
    059     */
    060    public FileUpload(final FileItemFactory fileItemFactory) {
    061        this.fileItemFactory = fileItemFactory;
    062    }
    063
    064    /**
    065     * Returns the factory class used when creating file items.
    066     *
    067     * @return The factory class for new file items.
    068     */
    069    @Override
    070    public FileItemFactory getFileItemFactory() {
    071        return fileItemFactory;
    072    }
    073
    074    /**
    075     * Sets the factory class to use when creating file items.
    076     *
    077     * @param fileItemFactory The factory class for new file items.
    078     */
    079    @Override
    080    public void setFileItemFactory(final FileItemFactory fileItemFactory) {
    081        this.fileItemFactory = fileItemFactory;
    082    }
    083
    084}