org.tinygroup.weblayer.webcontext.parser.impl
类 UploadServiceImpl

java.lang.Object
  继承者 org.tinygroup.support.BeanSupport
      继承者 org.tinygroup.weblayer.webcontext.parser.impl.UploadServiceImpl
所有已实现的接口:
org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, UploadConfiguration, UploadService

public class UploadServiceImpl
extends BeanSupport
implements UploadService

这个service可以处理multipart/form-data格式的HTTP POST请求,并将它们转换成form字段或是文件。

作者:
renhui

字段摘要
 
从接口 org.tinygroup.weblayer.webcontext.parser.upload.UploadConfiguration 继承的字段
FILE_SIZE_MAX_DEFAULT, SIZE_MAX_DEFAULT, SIZE_THRESHOLD_DEFAULT
 
构造方法摘要
UploadServiceImpl()
           
 
方法摘要
 String[] getFileNameKey()
          标准的上传文件请求中,包含这样的内容: Content-Disposition: attachment; filename=xxx.txt
 org.tinygroup.commons.tools.HumanReadableSize getFileSizeMax()
          取得单个文件允许的最大尺寸,超过此尺寸的文件将被抛弃。
 String getItemStorageBeanName()
           
 FileUploadReName getRename()
           
 File getRepository()
          取得暂存文件的目录。
 org.tinygroup.commons.tools.HumanReadableSize getSizeMax()
          取得HTTP请求的最大尺寸,超过此尺寸的请求将被抛弃。
 org.tinygroup.commons.tools.HumanReadableSize getSizeThreshold()
          取得将文件放在内存中的阈值,小于此值的文件被保存在内存中。
protected  void init()
           
 boolean isDiskItemFactory()
           
 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 setDiskItemFactory(boolean isDiskItemFactory)
           
 void setFileNameKey(String[] fileNameKey)
           
 void setFileSizeMax(org.tinygroup.commons.tools.HumanReadableSize fileSizeMax)
           
 void setItemStorageBeanName(String itemStorageBeanName)
           
 void setKeepFormFieldInMemory(boolean keepFormFieldInMemory)
           
 void setRename(FileUploadReName rename)
           
 void setRepository(File repository)
           
 void setSaveInFile(boolean saveInFile)
           
 void setSizeMax(org.tinygroup.commons.tools.HumanReadableSize sizeMax)
           
 void setSizeThreshold(org.tinygroup.commons.tools.HumanReadableSize sizeThreshold)
           
 
从类 org.tinygroup.support.BeanSupport 继承的方法
afterPropertiesSet, assertInitialized, destroy, dispose, getBeanDescription, getBeanDescription, getBeanInterface, getBeanName, isInitialized, postDispose, postInit, preDispose, preInit, resolveBeanInterface, setBeanName, toString
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

构造方法详细信息

UploadServiceImpl

public UploadServiceImpl()
方法详细信息

getRename

public FileUploadReName getRename()

setRename

public void setRename(FileUploadReName rename)

getRepository

public File getRepository()
从接口 UploadConfiguration 复制的描述
取得暂存文件的目录。

指定者:
接口 UploadConfiguration 中的 getRepository

getSizeMax

public org.tinygroup.commons.tools.HumanReadableSize getSizeMax()
从接口 UploadConfiguration 复制的描述
取得HTTP请求的最大尺寸,超过此尺寸的请求将被抛弃。单位:字节,值-1表示没有限制。

指定者:
接口 UploadConfiguration 中的 getSizeMax

getFileSizeMax

public org.tinygroup.commons.tools.HumanReadableSize getFileSizeMax()
从接口 UploadConfiguration 复制的描述
取得单个文件允许的最大尺寸,超过此尺寸的文件将被抛弃。单位:字节,值-1表示没有限制。

指定者:
接口 UploadConfiguration 中的 getFileSizeMax

getSizeThreshold

public org.tinygroup.commons.tools.HumanReadableSize getSizeThreshold()
从接口 UploadConfiguration 复制的描述
取得将文件放在内存中的阈值,小于此值的文件被保存在内存中。单位:字节。

指定者:
接口 UploadConfiguration 中的 getSizeThreshold

isKeepFormFieldInMemory

public boolean isKeepFormFieldInMemory()
从接口 UploadConfiguration 复制的描述
是否将普通的form field保持在内存里?当sizeThreshold值为0 的时候,该值自动为true

指定者:
接口 UploadConfiguration 中的 isKeepFormFieldInMemory

isSaveInFile

public boolean isSaveInFile()
指定者:
接口 UploadConfiguration 中的 isSaveInFile

setSizeMax

public void setSizeMax(org.tinygroup.commons.tools.HumanReadableSize sizeMax)

setFileSizeMax

public void setFileSizeMax(org.tinygroup.commons.tools.HumanReadableSize fileSizeMax)

setSizeThreshold

public void setSizeThreshold(org.tinygroup.commons.tools.HumanReadableSize sizeThreshold)

isDiskItemFactory

public boolean isDiskItemFactory()

getItemStorageBeanName

public String getItemStorageBeanName()

setDiskItemFactory

public void setDiskItemFactory(boolean isDiskItemFactory)

setItemStorageBeanName

public void setItemStorageBeanName(String itemStorageBeanName)

setKeepFormFieldInMemory

public void setKeepFormFieldInMemory(boolean keepFormFieldInMemory)

setRepository

public void setRepository(File repository)

setSaveInFile

public void setSaveInFile(boolean saveInFile)

getFileNameKey

public String[] getFileNameKey()
从接口 UploadConfiguration 复制的描述
标准的上传文件请求中,包含这样的内容: Content-Disposition: attachment; filename=xxx.txt 。然而有些不规范的应用,会取fname=xxx.txt。此变量为兼容这种情况而设。

指定者:
接口 UploadConfiguration 中的 getFileNameKey

setFileNameKey

public void setFileNameKey(String[] fileNameKey)

init

protected void init()
覆盖:
BeanSupport 中的 init

isMultipartContent

public boolean isMultipartContent(javax.servlet.http.HttpServletRequest request)
判断是否是符合RFC 1867标准的 multipart/form-data类型的HTTP请求。

指定者:
接口 UploadService 中的 isMultipartContent
参数:
request - HTTP请求
返回:
如果是,则返回true

parseRequest

public org.apache.commons.fileupload.FileItem[] parseRequest(javax.servlet.http.HttpServletRequest request)
解析符合RFC 1867标准的 multipart/form-data类型的HTTP请求。

指定者:
接口 UploadService 中的 parseRequest
参数:
request - HTTP请求
返回:
FileItem的列表,按其输入的顺序罗列
抛出:
UploadException - 如果解析时出错

parseRequest

public org.apache.commons.fileupload.FileItem[] parseRequest(javax.servlet.http.HttpServletRequest request,
                                                             UploadParameters params)
解析符合RFC 1867标准的 multipart/form-data类型的HTTP请求。

此方法覆盖了service的默认设置,适合于在action或servlet中手工执行。

指定者:
接口 UploadService 中的 parseRequest
参数:
request - HTTP请求
sizeThreshold - 文件放在内存中的阈值,小于此值的文件被保存在内存中。如果此值小于0,则使用预设的值
sizeMax - HTTP请求的最大尺寸,超过此尺寸的请求将被抛弃。
repositoryPath - 暂存上载文件的绝对路径
charset - 用来解析HTTP header的编码字符集
返回:
FileItem的列表,按其输入的顺序罗列
抛出:
UploadException - 如果解析时出错


Copyright © 2006–2014 开源组织. All rights reserved.