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
21 import org.apache.commons.fileupload.disk.DiskFileItemFactory;
22
23 /**
24 * <p>The default {@link org.apache.commons.fileupload.FileItemFactory}
25 * implementation. This implementation creates
26 * {@link org.apache.commons.fileupload.FileItem} instances which keep their
27 * content either in memory, for smaller items, or in a temporary file on disk,
28 * for larger items. The size threshold, above which content will be stored on
29 * disk, is configurable, as is the directory in which temporary files will be
30 * created.</p>
31 *
32 * <p>If not otherwise configured, the default configuration values are as
33 * follows:
34 * <ul>
35 * <li>Size threshold is 10KB.</li>
36 * <li>Repository is the system default temp directory, as returned by
37 * {@code System.getProperty("java.io.tmpdir")}.</li>
38 * </ul>
39 *
40 * @deprecated 1.1 Use {@code DiskFileItemFactory} instead.
41 */
42 @Deprecated
43 public class DefaultFileItemFactory extends DiskFileItemFactory {
44
45 /**
46 * Constructs an unconfigured instance of this class. The resulting factory
47 * may be configured by calling the appropriate setter methods.
48 *
49 * @deprecated 1.1 Use {@code DiskFileItemFactory} instead.
50 */
51 @Deprecated
52 public DefaultFileItemFactory() {
53 }
54
55 /**
56 * Constructs a preconfigured instance of this class.
57 *
58 * @param sizeThreshold The threshold, in bytes, below which items will be
59 * retained in memory and above which they will be
60 * stored as a file.
61 * @param repository The data repository, which is the directory in
62 * which files will be created, should the item size
63 * exceed the threshold.
64 *
65 * @deprecated 1.1 Use {@code DiskFileItemFactory} instead.
66 */
67 @Deprecated
68 public DefaultFileItemFactory(final int sizeThreshold, final File repository) {
69 super(sizeThreshold, repository);
70 }
71
72 /**
73 * Create a new {@link org.apache.commons.fileupload.DefaultFileItem}
74 * instance from the supplied parameters and the local factory
75 * configuration.
76 *
77 * @param fieldName The name of the form field.
78 * @param contentType The content type of the form field.
79 * @param isFormField {@code true} if this is a plain form field;
80 * {@code false} otherwise.
81 * @param fileName The name of the uploaded file, if any, as supplied
82 * by the browser or other client.
83 *
84 * @return The newly created file item.
85 * @deprecated 1.1 Use {@code DiskFileItemFactory} instead.
86 */
87 @Override
88 @Deprecated
89 public FileItem createItem(
90 final String fieldName,
91 final String contentType,
92 final boolean isFormField,
93 final String fileName
94 ) {
95 return new DefaultFileItem(fieldName, contentType,
96 isFormField, fileName, getSizeThreshold(), getRepository());
97 }
98
99 }