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