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