jfileupload.jspupload
Class FileUploadBean

java.lang.Object
  extended by jfileupload.jspupload.FileUploadBean
All Implemented Interfaces:
java.io.Serializable

public class FileUploadBean
extends java.lang.Object
implements java.io.Serializable

This class implements a Java bean for upload.

See Also:
Serialized Form

Field Summary
static int FOLDERSTORE
           
static int MAXUPLOADEDFILES
          Maximum uploaded files.
static long MAXUPLOADEDFILESIZE
          Size limit for an uploaded file.
static int MEMORYSTORE
           
static char SEPARATOR
           
static int TRANSFERBUFFERSIZE
           
static java.lang.String VERSION
           
 
Constructor Summary
FileUploadBean()
          Dummy constructor (needed for JavaBeans).
 
Method Summary
 long computeCRC32(java.io.File file, long offset)
          Compute CRC32 for a given filename.
 byte[] computeMD5(java.io.File file, long offset)
          Compute MD5 for a given filename.
 boolean getDump()
          Get dump mode.
 long getFilesizelimit()
          Returns maximum size allowed for an uploaded file.
 java.lang.String getFolderstore()
          Returns store folder.
 java.util.Vector getHistory()
          Returns a Vector[UploadParameters].
 java.util.Vector getMemorystore()
          Returns a Vector[UploadFile] from memory store.
 boolean getOverwrite()
          Returns overwrite state.
 java.lang.String getParsertmpdir()
          Gets multipart parser temporary directory if applicable.
 java.lang.String hexDump(byte[] in)
          Dump byte array to hexadecimal string.
 void resetStore()
          Cleans and resets the current store.
 void setDump(boolean dmp)
          Set dump mode.
 void setFilesizelimit(long max)
          Sets maximum size allowed for an uploaded file.
 void setFolderstore(java.lang.String serverfolder)
          Sets the remote store folder.
 void setMemorystore()
          Sets the memory store folder.
 void setOverwrite(boolean overwrite)
           
 void setParsertmpdir(java.lang.String dir)
          Sets temporary directory.
 void setStoremodel(int storeid)
          Selects the store model.
 void store(MultipartFormDataRequest mrequest)
          Moves all files to the store.
 void store(MultipartFormDataRequest mrequest, java.lang.String field)
          Moves one file identified by its form field to the store.
 void store(MultipartFormDataRequest mrequest, java.lang.String field, java.util.Map extra)
          Moves one file identified by its form field to the store and pass extra parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final java.lang.String VERSION
See Also:
Constant Field Values

MAXUPLOADEDFILES

public static final int MAXUPLOADEDFILES
Maximum uploaded files. Default is -1 unlimited

See Also:
Constant Field Values

MAXUPLOADEDFILESIZE

public static final long MAXUPLOADEDFILESIZE
Size limit for an uploaded file. Default is 1GB

See Also:
Constant Field Values

SEPARATOR

public static char SEPARATOR

MEMORYSTORE

public static final int MEMORYSTORE
See Also:
Constant Field Values

FOLDERSTORE

public static final int FOLDERSTORE
See Also:
Constant Field Values

TRANSFERBUFFERSIZE

public static int TRANSFERBUFFERSIZE
Constructor Detail

FileUploadBean

public FileUploadBean()
Dummy constructor (needed for JavaBeans).

Method Detail

setStoremodel

public void setStoremodel(int storeid)
                   throws UploadException
Selects the store model.

Parameters:
storeid -
Throws:
UploadException

getFolderstore

public java.lang.String getFolderstore()
Returns store folder.

Returns:
String

getMemorystore

public java.util.Vector getMemorystore()
Returns a Vector[UploadFile] from memory store.

Returns:
Vector

setMemorystore

public void setMemorystore()
                    throws UploadException
Sets the memory store folder. All files will be stored in memory.

Throws:
UploadException

setFolderstore

public void setFolderstore(java.lang.String serverfolder)
                    throws UploadException
Sets the remote store folder. This method check thats if the folder exists (and is RW). If not then it attempts to create it.
i.e. : /usr/client/www/uploaded

Parameters:
String - serverfolder
Throws:
UploadException

getDump

public boolean getDump()
Get dump mode.

Returns:
boolean

setDump

public void setDump(boolean dmp)
Set dump mode. Dump is disabled by default.

Parameters:
boolean - dmp

getParsertmpdir

public java.lang.String getParsertmpdir()
Gets multipart parser temporary directory if applicable.

Returns:

setParsertmpdir

public void setParsertmpdir(java.lang.String dir)
Sets temporary directory.

Parameters:
dir - Something like c:\\Temp or /tmp

getFilesizelimit

public long getFilesizelimit()
Returns maximum size allowed for an uploaded file.

Returns:
long

setFilesizelimit

public void setFilesizelimit(long max)
Sets maximum size allowed for an uploaded file.

Parameters:
max - long

setOverwrite

public void setOverwrite(boolean overwrite)

getOverwrite

public boolean getOverwrite()
Returns overwrite state.

Returns:
boolean

computeCRC32

public long computeCRC32(java.io.File file,
                         long offset)
Compute CRC32 for a given filename.

Parameters:
file -
offset - data range [0-offset] to compute CRC32, -1 for all data.
Returns:
-1 if cannot compute CRC32.

computeMD5

public byte[] computeMD5(java.io.File file,
                         long offset)
Compute MD5 for a given filename.

Parameters:
file -
offset - data range [0-offset] to compute MD5, -1 for all data.
Returns:
null if cannot compute MD5.

hexDump

public java.lang.String hexDump(byte[] in)
Dump byte array to hexadecimal string.

Parameters:
in -
Returns:
null if cannot compute

store

public void store(MultipartFormDataRequest mrequest,
                  java.lang.String field,
                  java.util.Map extra)
           throws UploadException,
                  java.io.IOException
Moves one file identified by its form field to the store and pass extra parameters.

Parameters:
mrequest -
field -
extra - parameters
Throws:
UploadException
java.io.IOException

store

public void store(MultipartFormDataRequest mrequest,
                  java.lang.String field)
           throws UploadException,
                  java.io.IOException
Moves one file identified by its form field to the store.

Parameters:
mrequest -
field -
Throws:
UploadException
java.io.IOException

store

public void store(MultipartFormDataRequest mrequest)
           throws UploadException,
                  java.io.IOException
Moves all files to the store.

Parameters:
mrequest -
Throws:
UploadException
java.io.IOException

getHistory

public java.util.Vector getHistory()
Returns a Vector[UploadParameters].

Returns:
Vector

resetStore

public void resetStore()
                throws UploadException,
                       java.io.IOException
Cleans and resets the current store.
MemoryStore will be empty.
All files in FolderStore will be deleted.

Throws:
UploadException
java.io.IOException