jodd.servlet.upload.impl
Class AdaptiveFileUpload

java.lang.Object
  extended by jodd.servlet.upload.FileUpload
      extended by jodd.servlet.upload.impl.AdaptiveFileUpload

public class AdaptiveFileUpload
extends FileUpload

Smart FileUpload implementation that defer the action of what to do with uploaded file for later. Internally, it stores uploaded file either in memory if it is small, or, in all other cases, it stores them in TEMP folder.


Field Summary
protected  boolean allowFileExtensions
           
protected  boolean breakOnError
           
protected  byte[] data
           
protected  java.lang.String[] fileExtensions
           
protected  int memoryThreshold
           
protected  java.io.File tempFile
           
protected static java.lang.String TMP_FILE_SUFFIX
           
protected  java.io.File uploadPath
           
 
Fields inherited from class jodd.servlet.upload.FileUpload
fileTooBig, header, input, maxFileSize, size, valid
 
Method Summary
protected  boolean checkUpload()
          Determines if upload is allowed.
 void delete()
          Deletes file uploaded item from disk or memory.
 byte[] getFileContent()
          Returns the content of file upload item.
 java.lang.String[] getFileExtensions()
           
 java.io.InputStream getFileInputStream()
          Returns input stream of uploaded file.
 int getMemoryThreshold()
           
 java.io.File getUploadPath()
           
 boolean isAllowFileExtensions()
           
 boolean isBreakOnError()
           
 boolean isInMemory()
          Returns true if file upload resides in memory.
protected  boolean matchFileExtension()
           
protected  void processStream()
          Process request input stream.
 java.io.File write(java.io.File destination)
          Writes file upload item to destination folder or to destination file.
 java.io.File write(java.lang.String destination)
          Writes file uploaded item.
 
Methods inherited from class jodd.servlet.upload.FileUpload
getHeader, getMaxFileSize, getSize, isFileTooBig, isUploaded, isValid, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TMP_FILE_SUFFIX

protected static final java.lang.String TMP_FILE_SUFFIX
See Also:
Constant Field Values

memoryThreshold

protected final int memoryThreshold

uploadPath

protected final java.io.File uploadPath

breakOnError

protected final boolean breakOnError

fileExtensions

protected final java.lang.String[] fileExtensions

allowFileExtensions

protected final boolean allowFileExtensions

tempFile

protected java.io.File tempFile

data

protected byte[] data
Method Detail

getMemoryThreshold

public int getMemoryThreshold()

getUploadPath

public java.io.File getUploadPath()

isBreakOnError

public boolean isBreakOnError()

getFileExtensions

public java.lang.String[] getFileExtensions()

isAllowFileExtensions

public boolean isAllowFileExtensions()

isInMemory

public boolean isInMemory()
Returns true if file upload resides in memory.

Specified by:
isInMemory in class FileUpload

matchFileExtension

protected boolean matchFileExtension()
                              throws java.io.IOException
Throws:
java.io.IOException

checkUpload

protected boolean checkUpload()
                       throws java.io.IOException
Determines if upload is allowed.

Throws:
java.io.IOException

processStream

protected void processStream()
                      throws java.io.IOException
Description copied from class: FileUpload
Process request input stream. Note that file size is unknown at this point. Therefore, the implementation should set the size attribute after successful processing. This method also must set the valid attribute.

Specified by:
processStream in class FileUpload
Throws:
java.io.IOException
See Also:
MultipartRequestInputStream

delete

public void delete()
Deletes file uploaded item from disk or memory.


write

public java.io.File write(java.lang.String destination)
                   throws java.io.IOException
Writes file uploaded item.

Throws:
java.io.IOException

write

public java.io.File write(java.io.File destination)
                   throws java.io.IOException
Writes file upload item to destination folder or to destination file. Returns the destination file.

Throws:
java.io.IOException

getFileContent

public byte[] getFileContent()
                      throws java.io.IOException
Returns the content of file upload item.

Specified by:
getFileContent in class FileUpload
Throws:
java.io.IOException

getFileInputStream

public java.io.InputStream getFileInputStream()
                                       throws java.io.IOException
Description copied from class: FileUpload
Returns input stream of uploaded file.

Specified by:
getFileInputStream in class FileUpload
Throws:
java.io.IOException


Copyright © 2003-2012 Jodd Team