public class UploadServiceImpl extends BeanSupport implements UploadService
multipart/form-data
格式的HTTP
POST请求,并将它们转换成form字段或是文件。FILE_SIZE_MAX_DEFAULT, SIZE_MAX_DEFAULT, SIZE_THRESHOLD_DEFAULT
Constructor and Description |
---|
UploadServiceImpl() |
Modifier and Type | Method and Description |
---|---|
String[] |
getFileNameKey()
标准的上传文件请求中,包含这样的内容:
Content-Disposition: attachment; filename=xxx.txt
。然而有些不规范的应用,会取fname=xxx.txt 。此变量为兼容这种情况而设。 |
HumanReadableSize |
getFileSizeMax()
取得单个文件允许的最大尺寸,超过此尺寸的文件将被抛弃。单位:字节,值
-1 表示没有限制。 |
String |
getItemStorageBeanName() |
FileUploadReName |
getRename() |
File |
getRepository()
取得暂存文件的目录。
|
HumanReadableSize |
getSizeMax()
取得HTTP请求的最大尺寸,超过此尺寸的请求将被抛弃。单位:字节,值
-1 表示没有限制。 |
HumanReadableSize |
getSizeThreshold()
取得将文件放在内存中的阈值,小于此值的文件被保存在内存中。单位:字节。
|
protected void |
init()
初始化bean。
|
boolean |
isDiskItemFactory() |
boolean |
isKeepFormFieldInMemory()
是否将普通的form field保持在内存里?当
sizeThreshold 值为0
的时候,该值自动为true 。 |
boolean |
isMultipartContent(javax.servlet.http.HttpServletRequest request)
判断是否是符合RFC 1867标准的
multipart/form-data 类型的HTTP请求。 |
boolean |
isSaveInFile() |
boolean |
isTemporary()
是否是临时目录,true:认为是临时文件,请求完毕会删除此临时文件。
|
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 |
setDiskItemFactory(boolean isDiskItemFactory) |
void |
setFileNameKey(String[] fileNameKey) |
void |
setFileSizeMax(HumanReadableSize fileSizeMax) |
void |
setItemStorageBeanName(String itemStorageBeanName) |
void |
setKeepFormFieldInMemory(boolean keepFormFieldInMemory) |
void |
setRename(FileUploadReName rename) |
void |
setRepository(File repository) |
void |
setSaveInFile(boolean saveInFile) |
void |
setSizeMax(HumanReadableSize sizeMax) |
void |
setSizeThreshold(HumanReadableSize sizeThreshold) |
void |
setTemporary(boolean isTemporary) |
afterPropertiesSet, assertInitialized, destroy, dispose, getBeanDescription, getBeanDescription, getBeanInterface, getBeanName, isInitialized, postDispose, postInit, preDispose, preInit, resolveBeanInterface, setBeanName, toString
public FileUploadReName getRename()
public void setRename(FileUploadReName rename)
public File getRepository()
UploadConfiguration
getRepository
in interface UploadConfiguration
public void setRepository(File repository)
public HumanReadableSize getSizeMax()
UploadConfiguration
-1
表示没有限制。getSizeMax
in interface UploadConfiguration
public void setSizeMax(HumanReadableSize sizeMax)
public HumanReadableSize getFileSizeMax()
UploadConfiguration
-1
表示没有限制。getFileSizeMax
in interface UploadConfiguration
public void setFileSizeMax(HumanReadableSize fileSizeMax)
public HumanReadableSize getSizeThreshold()
UploadConfiguration
getSizeThreshold
in interface UploadConfiguration
public void setSizeThreshold(HumanReadableSize sizeThreshold)
public boolean isKeepFormFieldInMemory()
UploadConfiguration
sizeThreshold
值为0
的时候,该值自动为true
。isKeepFormFieldInMemory
in interface UploadConfiguration
public void setKeepFormFieldInMemory(boolean keepFormFieldInMemory)
public boolean isSaveInFile()
isSaveInFile
in interface UploadConfiguration
public void setSaveInFile(boolean saveInFile)
public boolean isDiskItemFactory()
isDiskItemFactory
in interface UploadConfiguration
public void setDiskItemFactory(boolean isDiskItemFactory)
public String getItemStorageBeanName()
getItemStorageBeanName
in interface UploadConfiguration
public void setItemStorageBeanName(String itemStorageBeanName)
public String[] getFileNameKey()
UploadConfiguration
Content-Disposition: attachment; filename=xxx.txt
。然而有些不规范的应用,会取fname=xxx.txt
。此变量为兼容这种情况而设。getFileNameKey
in interface UploadConfiguration
public void setFileNameKey(String[] fileNameKey)
public boolean isTemporary()
UploadConfiguration
isTemporary
in interface UploadConfiguration
public void setTemporary(boolean isTemporary)
protected void init()
BeanSupport
init
in class BeanSupport
public boolean isMultipartContent(javax.servlet.http.HttpServletRequest request)
multipart/form-data
类型的HTTP请求。isMultipartContent
in interface UploadService
request
- HTTP请求true
public org.apache.commons.fileupload.FileItem[] parseRequest(javax.servlet.http.HttpServletRequest request)
multipart/form-data
类型的HTTP请求。parseRequest
in interface UploadService
request
- HTTP请求FileItem
的列表,按其输入的顺序罗列UploadException
- 如果解析时出现异常public org.apache.commons.fileupload.FileItem[] parseRequest(javax.servlet.http.HttpServletRequest request, UploadParameters params)
parseRequest
in interface UploadService
request
- HTTP请求params
- upload参数FileItem
的列表,按其输入的顺序罗列UploadException
- 如果解析时出现异常Copyright © 2006–2018 TinyGroup. All rights reserved.