📄 servletmultipartrequest.java
字号:
/*
*
* Copyright (c) 2004 SourceTap - www.sourcetap.com
*
* The contents of this file are subject to the SourceTap Public License
* ("License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
*/
package http.utils.multipartrequest;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
/**
Wrapper for MultipartRequest
*/
public class ServletMultipartRequest extends MultipartRequest {
/**
* Constructor.
*
* @param request The HttpServletRequest will be used to initialise the MultipartRequest super class.
* @param strSaveDirectory The temporary directory to save the file from where they can then be moved to wherever by the
* calling process. <b>If you specify <u>null</u> for this parameter, then any files uploaded
* will be silently ignored.</B>
*
* @exception IllegalArgumentException If the request.getContentType() does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
* @exception IOException If the request.getContentLength() is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
*
* @see MultipartRequest#MAX_READ_BYTES
*/
public ServletMultipartRequest(HttpServletRequest request,
String strSaveDirectory) throws IllegalArgumentException, IOException {
super(null, request.getContentType(), request.getContentLength(),
request.getInputStream(), strSaveDirectory, null,
MultipartRequest.MAX_READ_BYTES);
}
/**
* Constructor.
*
* @param request The HttpServletRequest will be used to initialise the MultipartRequest super class.
* @param strSaveDirectory The temporary directory to save the file from where they can then be moved to wherever by the
* calling process. <b>If you specify <u>null</u> for this parameter, then any files uploaded
* will be silently ignored.</B>
* @param strFilePrefix A prefix that will be prepended to the saved file
*
* @exception IllegalArgumentException If the request.getContentType() does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
* @exception IOException If the request.getContentLength() is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
*
* @see MultipartRequest#MAX_READ_BYTES
*/
public ServletMultipartRequest(HttpServletRequest request,
String strSaveDirectory, String strFilePrefix)
throws IllegalArgumentException, IOException {
super(null, request.getContentType(), request.getContentLength(),
request.getInputStream(), strSaveDirectory, strFilePrefix,
MultipartRequest.MAX_READ_BYTES);
}
/**
* Constructor.
*
* @param request The HttpServletRequest will be used to initialise the MultipartRequest super class.
* @param strSaveDirectory The temporary directory to save the file from where they can then be moved to wherever by the
* calling process. <b>If you specify <u>null</u> for this parameter, then any files uploaded
* will be silently ignored.</B>
* @param intMaxReadBytes Overrides the MAX_BYTES_READ value, to allow arbitrarily long files.
*
* @exception IllegalArgumentException If the request.getContentType() does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
* @exception IOException If the request.getContentLength() is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
*
* @see MultipartRequest#MAX_READ_BYTES
*/
public ServletMultipartRequest(HttpServletRequest request,
String strSaveDirectory, int intMaxReadBytes)
throws IllegalArgumentException, IOException {
super(null, request.getContentType(), request.getContentLength(),
request.getInputStream(), strSaveDirectory, null, intMaxReadBytes);
}
/**
* Constructor.
*
* @param request The HttpServletRequest will be used to initialise the MultipartRequest super class.
* @param strSaveDirectory The temporary directory to save the file from where they can then be moved to wherever by the
* calling process. <b>If you specify <u>null</u> for this parameter, then any files uploaded
* will be silently ignored.</B>
* @param strFilePrefix A prefix that will be prepended to the saved file
* @param intMaxReadBytes Overrides the MAX_BYTES_READ value, to allow arbitrarily long files.
*
* @exception IllegalArgumentException If the request.getContentType() does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
* @exception IOException If the request.getContentLength() is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
*
* @see MultipartRequest#MAX_READ_BYTES
*/
public ServletMultipartRequest(HttpServletRequest request,
String strSaveDirectory, String strFilePrefix, int intMaxReadBytes)
throws IllegalArgumentException, IOException {
super(null, request.getContentType(), request.getContentLength(),
request.getInputStream(), strSaveDirectory, null, intMaxReadBytes);
}
/**
* Constructor - load into memory constructor
*
* @param request The HttpServletRequest will be used to initialise the MultipartRequest super class.
* @param intMaxReadBytes Overrides the MAX_BYTES_READ value, to allow arbitrarily long files.
*
* @exception IllegalArgumentException If the request.getContentType() does not contain a Content-Type of "multipart/form-data" or the boundary is not found.
* @exception IOException If the request.getContentLength() is higher than MAX_READ_BYTES or strSaveDirectory is invalid or cannot be written to.
*
* @see MultipartRequest#MAX_READ_BYTES
*/
public ServletMultipartRequest(HttpServletRequest request,
int intMaxReadBytes) throws IllegalArgumentException, IOException {
super(null, request.getContentType(), request.getContentLength(),
request.getInputStream(), intMaxReadBytes);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -