public class UploadServiceImpl extends BeanSupport implements UploadService
multipart/form-data格式的HTTP
POST请求,并将它们转换成form字段或是文件。FILE_SIZE_MAX_DEFAULT, SIZE_MAX_DEFAULT, SIZE_THRESHOLD_DEFAULT| 构造器和说明 |
|---|
UploadServiceImpl() |
| 限定符和类型 | 方法和说明 |
|---|---|
String[] |
getFileNameKey()
标准的上传文件请求中,包含这样的内容:
Content-Disposition: attachment; filename=xxx.txt
。 |
HumanReadableSize |
getFileSizeMax()
取得单个文件允许的最大尺寸,超过此尺寸的文件将被抛弃。
|
FileUploadReName |
getRename() |
File |
getRepository()
取得暂存文件的目录。
|
HumanReadableSize |
getSizeMax()
取得HTTP请求的最大尺寸,超过此尺寸的请求将被抛弃。
|
HumanReadableSize |
getSizeThreshold()
取得将文件放在内存中的阈值,小于此值的文件被保存在内存中。
|
protected void |
init() |
boolean |
isKeepFormFieldInMemory()
是否将普通的form field保持在内存里?
|
boolean |
isMultipartContent(javax.servlet.http.HttpServletRequest request)
判断是否是符合RFC 1867标准的
multipart/form-data类型的HTTP请求。 |
boolean |
isSaveInFile() |
org.apache.commons.fileupload.FileItem[] |
parseRequest(javax.servlet.http.HttpServletRequest request)
解析符合RFC 1867标准的
multipart/form-data类型的HTTP请求。 |
org.apache.commons.fileupload.FileItem[] |
parseRequest(javax.servlet.http.HttpServletRequest request,
UploadParameters params)
解析符合RFC 1867标准的
multipart/form-data类型的HTTP请求。 |
void |
setFileNameKey(String[] fileNameKey) |
void |
setFileSizeMax(HumanReadableSize fileSizeMax) |
void |
setKeepFormFieldInMemory(boolean keepFormFieldInMemory) |
void |
setRename(FileUploadReName rename) |
void |
setRepository(File repository) |
void |
setSaveInFile(boolean saveInFile) |
void |
setSizeMax(HumanReadableSize sizeMax) |
void |
setSizeThreshold(HumanReadableSize sizeThreshold) |
afterPropertiesSet, assertInitialized, destroy, dispose, getBeanDescription, getBeanDescription, getBeanInterface, getBeanName, isInitialized, postDispose, postInit, preDispose, preInit, resolveBeanInterface, setBeanName, toStringpublic FileUploadReName getRename()
public void setRename(FileUploadReName rename)
public File getRepository()
UploadConfigurationgetRepository 在接口中 UploadConfigurationpublic HumanReadableSize getSizeMax()
UploadConfiguration-1表示没有限制。getSizeMax 在接口中 UploadConfigurationpublic HumanReadableSize getFileSizeMax()
UploadConfiguration-1表示没有限制。getFileSizeMax 在接口中 UploadConfigurationpublic HumanReadableSize getSizeThreshold()
UploadConfigurationgetSizeThreshold 在接口中 UploadConfigurationpublic boolean isKeepFormFieldInMemory()
UploadConfigurationsizeThreshold值为0
的时候,该值自动为true。isKeepFormFieldInMemory 在接口中 UploadConfigurationpublic boolean isSaveInFile()
isSaveInFile 在接口中 UploadConfigurationpublic void setSizeMax(HumanReadableSize sizeMax)
public void setFileSizeMax(HumanReadableSize fileSizeMax)
public void setSizeThreshold(HumanReadableSize sizeThreshold)
public void setKeepFormFieldInMemory(boolean keepFormFieldInMemory)
public void setRepository(File repository)
public void setSaveInFile(boolean saveInFile)
public String[] getFileNameKey()
UploadConfigurationContent-Disposition: attachment; filename=xxx.txt
。然而有些不规范的应用,会取fname=xxx.txt。此变量为兼容这种情况而设。getFileNameKey 在接口中 UploadConfigurationpublic void setFileNameKey(String[] fileNameKey)
protected void init()
init 在类中 BeanSupportpublic boolean isMultipartContent(javax.servlet.http.HttpServletRequest request)
multipart/form-data类型的HTTP请求。isMultipartContent 在接口中 UploadServicerequest - HTTP请求truepublic org.apache.commons.fileupload.FileItem[] parseRequest(javax.servlet.http.HttpServletRequest request)
multipart/form-data类型的HTTP请求。parseRequest 在接口中 UploadServicerequest - HTTP请求FileItem的列表,按其输入的顺序罗列UploadException - 如果解析时出错public org.apache.commons.fileupload.FileItem[] parseRequest(javax.servlet.http.HttpServletRequest request,
UploadParameters params)
parseRequest 在接口中 UploadServicerequest - HTTP请求sizeThreshold - 文件放在内存中的阈值,小于此值的文件被保存在内存中。如果此值小于0,则使用预设的值sizeMax - HTTP请求的最大尺寸,超过此尺寸的请求将被抛弃。repositoryPath - 暂存上载文件的绝对路径charset - 用来解析HTTP header的编码字符集FileItem的列表,按其输入的顺序罗列UploadException - 如果解析时出错Copyright © 2006-2013 开源组织. All Rights Reserved.