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 019import java.io.File; 020 021import org.apache.commons.fileupload.disk.DiskFileItemFactory; 022 023/** 024 * <p>The default {@link org.apache.commons.fileupload.FileItemFactory} 025 * implementation. This implementation creates 026 * {@link org.apache.commons.fileupload.FileItem} instances which keep their 027 * content either in memory, for smaller items, or in a temporary file on disk, 028 * for larger items. The size threshold, above which content will be stored on 029 * disk, is configurable, as is the directory in which temporary files will be 030 * created.</p> 031 * 032 * <p>If not otherwise configured, the default configuration values are as 033 * follows: 034 * <ul> 035 * <li>Size threshold is 10KB.</li> 036 * <li>Repository is the system default temp directory, as returned by 037 * {@code System.getProperty("java.io.tmpdir")}.</li> 038 * </ul> 039 * 040 * @deprecated 1.1 Use {@code DiskFileItemFactory} instead. 041 */ 042@Deprecated 043public class DefaultFileItemFactory extends DiskFileItemFactory { 044 045 /** 046 * Constructs an unconfigured instance of this class. The resulting factory 047 * may be configured by calling the appropriate setter methods. 048 * 049 * @deprecated 1.1 Use {@code DiskFileItemFactory} instead. 050 */ 051 @Deprecated 052 public DefaultFileItemFactory() { 053 } 054 055 /** 056 * Constructs a preconfigured instance of this class. 057 * 058 * @param sizeThreshold The threshold, in bytes, below which items will be 059 * retained in memory and above which they will be 060 * stored as a file. 061 * @param repository The data repository, which is the directory in 062 * which files will be created, should the item size 063 * exceed the threshold. 064 * 065 * @deprecated 1.1 Use {@code DiskFileItemFactory} instead. 066 */ 067 @Deprecated 068 public DefaultFileItemFactory(final int sizeThreshold, final File repository) { 069 super(sizeThreshold, repository); 070 } 071 072 /** 073 * Create a new {@link org.apache.commons.fileupload.DefaultFileItem} 074 * instance from the supplied parameters and the local factory 075 * configuration. 076 * 077 * @param fieldName The name of the form field. 078 * @param contentType The content type of the form field. 079 * @param isFormField {@code true} if this is a plain form field; 080 * {@code false} otherwise. 081 * @param fileName The name of the uploaded file, if any, as supplied 082 * by the browser or other client. 083 * 084 * @return The newly created file item. 085 * @deprecated 1.1 Use {@code DiskFileItemFactory} instead. 086 */ 087 @Override 088 @Deprecated 089 public FileItem createItem( 090 final String fieldName, 091 final String contentType, 092 final boolean isFormField, 093 final String fileName 094 ) { 095 return new DefaultFileItem(fieldName, contentType, 096 isFormField, fileName, getSizeThreshold(), getRepository()); 097 } 098 099}