atg.servlet
Class UploadedFile

java.lang.Object
  extended by atg.servlet.UploadedFile

public class UploadedFile
extends java.lang.Object

This represents a single uploaded file extracted from a multipart form. The contents of the file are extracted using an InputStream. The contents of the file might come from an in-memory buffer, or from a temporary file.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Constructor Summary
UploadedFile(java.lang.String pFilename, java.lang.String pContentType, int pFileSize, byte[] pBuf)
          Constructs a new UploadedFile whose contents are stored in the specified byte array.
UploadedFile(java.lang.String pFilename, java.lang.String pContentType, int pFileSize, java.io.File pFile)
          Constructs a new UploadedFile whose contents are stored in the specified temporary file.
 
Method Summary
 void deleteTemporaryFile()
          Deletes the temporary file held by this value.
 java.lang.String getContentType()
          Returns the content type of the uploaded file, as determined by the browser that uploaded the file.
 java.lang.String getFilename()
          Returns the file name of the uploaded file.
 int getFileSize()
          Returns the size of the uploaded file, in bytes.
 java.io.File getInputFile()
          Returns the uploaded file object (if there is one).
 java.io.InputStream getInputStream()
          Returns an InputStream that gives access to the contents of the uploaded file.
 void setFilename(java.lang.String pFilename)
          Sets the file name of the uploaded file.
 byte[] toByteArray()
          This is a convenience method that calls getInputStream() then reads all of the data from the input stream into a byte array that is returned.
 java.lang.String toString()
          Returns a String representation of this, which is just the client's filename.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

UploadedFile

public UploadedFile(java.lang.String pFilename,
                    java.lang.String pContentType,
                    int pFileSize,
                    java.io.File pFile)
Constructs a new UploadedFile whose contents are stored in the specified temporary file.


UploadedFile

public UploadedFile(java.lang.String pFilename,
                    java.lang.String pContentType,
                    int pFileSize,
                    byte[] pBuf)
Constructs a new UploadedFile whose contents are stored in the specified byte array.

Method Detail

deleteTemporaryFile

public void deleteTemporaryFile()
Deletes the temporary file held by this value. This should only be called by the system, not by applications.


toString

public java.lang.String toString()
Returns a String representation of this, which is just the client's filename. This is used by droplets to display the default value in an input field.

Overrides:
toString in class java.lang.Object

setFilename

public void setFilename(java.lang.String pFilename)
Sets the file name of the uploaded file. Such filename should really be a final value in this class, but unfortunately we're doing the character decoding for non-ASCII file names just too late for that.


getFilename

public java.lang.String getFilename()
Returns the file name of the uploaded file. This file name is the name of the file on the client's machine, not the name of the temporary file.


getContentType

public java.lang.String getContentType()
Returns the content type of the uploaded file, as determined by the browser that uploaded the file.


getFileSize

public int getFileSize()
Returns the size of the uploaded file, in bytes.


getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Returns an InputStream that gives access to the contents of the uploaded file.

Throws:
java.io.IOException

getInputFile

public java.io.File getInputFile()
Returns the uploaded file object (if there is one). For small files, this may return null if the uploaded data is only stored in memory. For typical uses, you should use getInputStream method to read the data which will work even if the file is not on disk.

See Also:
getInputStream()

toByteArray

public byte[] toByteArray()
                   throws java.io.IOException
This is a convenience method that calls getInputStream() then reads all of the data from the input stream into a byte array that is returned.

Throws:
java.io.IOException