1 package http.utils.multipartrequest;
2
3 import java.io.PrintWriter;
4 import java.io.IOException;
5
6 /***
7 A Multipart form data parser. Parses an input stream and writes out any files found,
8 making available a hashtable of other url parameters. As of version 1.17 the files can
9 be saved to memory, and optionally written to a database, etc.
10
11 <BR>
12 <BR>
13 Copyright (c)2001-2003 Jason Pell.
14 <BR>
15
16 <PRE>
17 This library is free software; you can redistribute it and/or
18 modify it under the terms of the GNU Lesser General Public
19 License as published by the Free Software Foundation; either
20 version 2.1 of the License, or (at your option) any later version.
21 <BR>
22 This library is distributed in the hope that it will be useful,
23 but WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 Lesser General Public License for more details.
26 <BR>
27 You should have received a copy of the GNU Lesser General Public
28 License along with this library; if not, write to the Free Software
29 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 <BR>
31 Email: jasonpell@hotmail.com
32 Url: http://www.geocities.com/jasonpell
33 </PRE>
34
35 Wrapper for MultipartRequest
36 */
37 public class CgiMultipartRequest extends MultipartRequest
38 {
39 /***
40 * Standard Constructor
41 *
42 * @param strSaveDirectory The temporary directory to save the file from where they can then be moved to wherever by the
43 * calling process. <b>If you specify <u>null</u> for this parameter, then any files uploaded
44 * will be silently ignored.</B>
45 *
46 * @exception IllegalArgumentException If the System.getProperty("CONTENT_TYPE") does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
47 * @exception IOException If the System.getProperty("CONTENT_LENGTH") is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
48 *
49 * @see MultipartRequest#MAX_READ_BYTES
50 */
51 public CgiMultipartRequest(String strSaveDirectory) throws IllegalArgumentException, IOException, NumberFormatException
52 {
53 super(null,
54 System.getProperty("CONTENT_TYPE"),
55 Integer.parseInt(System.getProperty("CONTENT_LENGTH")),
56 System.in,
57 strSaveDirectory,
58 MultipartRequest.MAX_READ_BYTES,
59 null);
60 }
61
62 /***
63 * Standard Constructor
64 *
65 * @param strSaveDirectory The temporary directory to save the file from where they can then be moved to wherever by the
66 * calling process. <b>If you specify <u>null</u> for this parameter, then any files uploaded
67 * will be silently ignored.</B>
68 * @param intMaxReadBytes Overrides the MAX_BYTES_READ value, to allow arbitrarily long files.
69 *
70 * @exception IllegalArgumentException If the System.getProperty("CONTENT_TYPE") does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
71 * @exception IOException If the System.getProperty("CONTENT_LENGTH") is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
72 *
73 * @see MultipartRequest#MAX_READ_BYTES
74 */
75 public CgiMultipartRequest(String strSaveDirectory, int intMaxReadBytes) throws IllegalArgumentException, IOException, NumberFormatException
76 {
77 super(null,
78 System.getProperty("CONTENT_TYPE"),
79 Integer.parseInt(System.getProperty("CONTENT_LENGTH")),
80 System.in,
81 strSaveDirectory,
82 intMaxReadBytes,
83 null);
84 }
85
86 /***
87 * Memory Constructor
88 *
89 * @param debug A PrintWriter that can be used for debugging.
90 * @param intMaxReadBytes Overrides the MAX_BYTES_READ value, to allow arbitrarily long files.
91 *
92 * @exception IllegalArgumentException If the System.getProperty("CONTENT_TYPE") does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
93 * @exception IOException If the System.getProperty("CONTENT_LENGTH") is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
94 *
95 * @see MultipartRequest#MAX_READ_BYTES
96 */
97 public CgiMultipartRequest(int intMaxReadBytes) throws IllegalArgumentException, IOException, NumberFormatException
98 {
99 super(null,
100 System.getProperty("CONTENT_TYPE"),
101 Integer.parseInt(System.getProperty("CONTENT_LENGTH")),
102 System.in,
103 intMaxReadBytes,
104 null);
105 }
106 }