001: /*
002: *
003: * Copyright (c) 2004 SourceTap - www.sourcetap.com
004: *
005: * The contents of this file are subject to the SourceTap Public License
006: * ("License"); You may not use this file except in compliance with the
007: * License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
008: * Software distributed under the License is distributed on an "AS IS" basis,
009: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
010: * the specific language governing rights and limitations under the License.
011: *
012: * The above copyright notice and this permission notice shall be included
013: * in all copies or substantial portions of the Software.
014: *
015: */
016:
017: package http.utils.multipartrequest;
018:
019: import java.io.IOException;
020:
021: import javax.servlet.http.HttpServletRequest;
022:
023: /**
024: Wrapper for MultipartRequest
025: */
026: public class ServletMultipartRequest extends MultipartRequest {
027: /**
028: * Constructor.
029: *
030: * @param request The HttpServletRequest will be used to initialise the MultipartRequest super class.
031: * @param strSaveDirectory The temporary directory to save the file from where they can then be moved to wherever by the
032: * calling process. <b>If you specify <u>null</u> for this parameter, then any files uploaded
033: * will be silently ignored.</B>
034: *
035: * @exception IllegalArgumentException If the request.getContentType() does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
036: * @exception IOException If the request.getContentLength() is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
037: *
038: * @see MultipartRequest#MAX_READ_BYTES
039: */
040: public ServletMultipartRequest(HttpServletRequest request,
041: String strSaveDirectory) throws IllegalArgumentException,
042: IOException {
043: super (null, request.getContentType(), request
044: .getContentLength(), request.getInputStream(),
045: strSaveDirectory, null, MultipartRequest.MAX_READ_BYTES);
046: }
047:
048: /**
049: * Constructor.
050: *
051: * @param request The HttpServletRequest will be used to initialise the MultipartRequest super class.
052: * @param strSaveDirectory The temporary directory to save the file from where they can then be moved to wherever by the
053: * calling process. <b>If you specify <u>null</u> for this parameter, then any files uploaded
054: * will be silently ignored.</B>
055: * @param strFilePrefix A prefix that will be prepended to the saved file
056: *
057: * @exception IllegalArgumentException If the request.getContentType() does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
058: * @exception IOException If the request.getContentLength() is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
059: *
060: * @see MultipartRequest#MAX_READ_BYTES
061: */
062: public ServletMultipartRequest(HttpServletRequest request,
063: String strSaveDirectory, String strFilePrefix)
064: throws IllegalArgumentException, IOException {
065: super (null, request.getContentType(), request
066: .getContentLength(), request.getInputStream(),
067: strSaveDirectory, strFilePrefix,
068: MultipartRequest.MAX_READ_BYTES);
069: }
070:
071: /**
072: * Constructor.
073: *
074: * @param request The HttpServletRequest will be used to initialise the MultipartRequest super class.
075: * @param strSaveDirectory The temporary directory to save the file from where they can then be moved to wherever by the
076: * calling process. <b>If you specify <u>null</u> for this parameter, then any files uploaded
077: * will be silently ignored.</B>
078: * @param intMaxReadBytes Overrides the MAX_BYTES_READ value, to allow arbitrarily long files.
079: *
080: * @exception IllegalArgumentException If the request.getContentType() does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
081: * @exception IOException If the request.getContentLength() is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
082: *
083: * @see MultipartRequest#MAX_READ_BYTES
084: */
085: public ServletMultipartRequest(HttpServletRequest request,
086: String strSaveDirectory, int intMaxReadBytes)
087: throws IllegalArgumentException, IOException {
088: super (null, request.getContentType(), request
089: .getContentLength(), request.getInputStream(),
090: strSaveDirectory, null, intMaxReadBytes);
091: }
092:
093: /**
094: * Constructor.
095: *
096: * @param request The HttpServletRequest will be used to initialise the MultipartRequest super class.
097: * @param strSaveDirectory The temporary directory to save the file from where they can then be moved to wherever by the
098: * calling process. <b>If you specify <u>null</u> for this parameter, then any files uploaded
099: * will be silently ignored.</B>
100: * @param strFilePrefix A prefix that will be prepended to the saved file
101: * @param intMaxReadBytes Overrides the MAX_BYTES_READ value, to allow arbitrarily long files.
102: *
103: * @exception IllegalArgumentException If the request.getContentType() does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
104: * @exception IOException If the request.getContentLength() is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
105: *
106: * @see MultipartRequest#MAX_READ_BYTES
107: */
108: public ServletMultipartRequest(HttpServletRequest request,
109: String strSaveDirectory, String strFilePrefix,
110: int intMaxReadBytes) throws IllegalArgumentException,
111: IOException {
112: super (null, request.getContentType(), request
113: .getContentLength(), request.getInputStream(),
114: strSaveDirectory, null, intMaxReadBytes);
115: }
116:
117: /**
118: * Constructor - load into memory constructor
119: *
120: * @param request The HttpServletRequest will be used to initialise the MultipartRequest super class.
121: * @param intMaxReadBytes Overrides the MAX_BYTES_READ value, to allow arbitrarily long files.
122: *
123: * @exception IllegalArgumentException If the request.getContentType() does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
124: * @exception IOException If the request.getContentLength() is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
125: *
126: * @see MultipartRequest#MAX_READ_BYTES
127: */
128: public ServletMultipartRequest(HttpServletRequest request,
129: int intMaxReadBytes) throws IllegalArgumentException,
130: IOException {
131: super(null, request.getContentType(), request
132: .getContentLength(), request.getInputStream(),
133: intMaxReadBytes);
134: }
135: }
|