kom.tools.web
Class Upload

java.lang.Object
  |
  +--kom.tools.web.Upload

public class Upload
extends java.lang.Object

Uploaded data from the Client


Field Summary
protected  java.lang.String cid
           
protected  java.lang.String desc
           
protected  java.lang.String extra
           
protected  java.lang.String fileName
           
protected  long id
           
protected  java.lang.String mimeType
           
(package private) static java.lang.String prefix
           
protected  java.lang.String tmpDir
           
protected  java.io.File tmpFile
           
protected  java.lang.String tmpName
           
protected  java.lang.String uid
           
 
Constructor Summary
Upload(java.lang.String fileName, java.lang.String mimeType, java.lang.String tmpDir, long id)
          Constructor
 
Method Summary
 java.lang.String fileName()
          Gets the path of the original file
 void finalize()
          Removes the temporary file by finalization
 java.lang.String getContentId()
          Gets a Content-Id of the uploaded data
 java.io.InputStream getContents()
          Gets contents as an InputStream
 java.lang.String getDescription()
          Gets contentDescription
 java.lang.String getExtra()
          Gets extra data
 long getId()
          Gets the id of the uploaded data
(package private)  java.io.OutputStream getOutputStream()
          Gets the output stream (enables writing)
 java.lang.String getUid()
          Gets user id (uid)
protected  void handleName()
          Removes directory path from the file name.
 java.lang.String mimeType()
          Gets Content-Type
 void setContentId(java.lang.String s)
          Sets cid (Content-Id value)
 void setDescription(java.lang.String s)
          Sets contentDescription
 void setExtra(java.lang.String s)
          Sets extra data
 void setFileName(java.lang.String fn)
          Sets the client file path
 void setMIMEType(java.lang.String mime)
          Sets the MIME type
 void setUid(java.lang.String s)
          Sets uid
 boolean store(java.lang.String dataDir, java.lang.String fileName)
          Stores the data in a temporary file
 java.io.File tempFile()
           
 java.lang.String toString()
          Converts the data to a String Should be used only for small files
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

fileName

protected java.lang.String fileName

mimeType

protected java.lang.String mimeType

desc

protected java.lang.String desc

extra

protected java.lang.String extra

tmpDir

protected java.lang.String tmpDir

id

protected long id

cid

protected java.lang.String cid

uid

protected java.lang.String uid

tmpName

protected java.lang.String tmpName

tmpFile

protected java.io.File tmpFile

prefix

static final java.lang.String prefix
Constructor Detail

Upload

public Upload(java.lang.String fileName,
              java.lang.String mimeType,
              java.lang.String tmpDir,
              long id)
Constructor
Parameters:
fileName - File path on the client side
mimeType - MIME type (Content-Type) string
tmpDir - Directory for temporary file(s)
id - Unique id no
Method Detail

tempFile

public java.io.File tempFile()

handleName

protected void handleName()
Removes directory path from the file name.

setFileName

public void setFileName(java.lang.String fn)
Sets the client file path
Parameters:
file - path (client side)

setDescription

public void setDescription(java.lang.String s)
Sets contentDescription
Parameters:
s - Value

setContentId

public void setContentId(java.lang.String s)
Sets cid (Content-Id value)
Parameters:
s - Value

setUid

public void setUid(java.lang.String s)
Sets uid
Parameters:
s - Value

setExtra

public void setExtra(java.lang.String s)
Sets extra data
Parameters:
s - Value

setMIMEType

public void setMIMEType(java.lang.String mime)
Sets the MIME type
Parameters:
mime - New MIME type (no action if null)

getOutputStream

java.io.OutputStream getOutputStream()
Gets the output stream (enables writing)
Returns:
OutputStream for file defined by tmpDir, prefix and id

getContents

public java.io.InputStream getContents()
Gets contents as an InputStream
Returns:
FileInputStream

toString

public java.lang.String toString()
Converts the data to a String Should be used only for small files
Overrides:
toString in class java.lang.Object
Returns:
String representation of the temp file

getId

public long getId()
Gets the id of the uploaded data
Returns:
id value

getContentId

public java.lang.String getContentId()
Gets a Content-Id of the uploaded data
Returns:
cid value

mimeType

public java.lang.String mimeType()
Gets Content-Type
Returns:
mimeType (Content-Type value)

fileName

public java.lang.String fileName()
Gets the path of the original file
Returns:
File path as defined by client

getDescription

public java.lang.String getDescription()
Gets contentDescription

getExtra

public java.lang.String getExtra()
Gets extra data

getUid

public java.lang.String getUid()
Gets user id (uid)

finalize

public void finalize()
Removes the temporary file by finalization
Overrides:
finalize in class java.lang.Object

store

public boolean store(java.lang.String dataDir,
                     java.lang.String fileName)
Stores the data in a temporary file
Parameters:
dataDir - Destination directory
fileName - Destination file name
Returns:
true on success