|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.turbine.util.upload.FileItem
This class represents a file that was received by Turbine using
multipart/form-data
POST request.
After retrieving an instance of this class from the ParameterParser
(see
ParameterParser.getFileItem(String)
and ParameterParser.getFileItems(String)
) you can use it to acces the
data that was sent by the browser. You may either request all
contents of file at once using get()
or request an InputStream
with getStream()
and
process the file without attempting to load it into memory, which
may come handy with large files.
Implements the javax.activation.DataSource interface (which allows
for example the adding of a FileItem as an attachment to a multipart
email).
Field Summary | |
protected java.io.ByteArrayOutputStream |
byteStream
Deprecated. Temporary storage for in-memory files. |
protected byte[] |
content
Deprecated. Cached contents of the file. |
protected java.lang.String |
contentType
Deprecated. The content type passed by the browser or null if
not defined. |
static int |
DEFAULT_UPLOAD_SIZE_THRESHOLD
Deprecated. The maximal size of request that will have it's elements stored in memory. |
protected java.lang.String |
fileName
Deprecated. The original filename in the user's filesystem. |
protected java.io.File |
storeLocation
Deprecated. Temporary storage location. |
Constructor Summary | |
protected |
FileItem(java.lang.String fileName,
java.lang.String contentType)
Deprecated. Constructs a new FileItem . |
Method Summary | |
protected void |
finalize()
Deprecated. Removes the file contents from the temporary storage. |
byte[] |
get()
Deprecated. Returns the contents of the file as an array of bytes. |
java.lang.String |
getContentType()
Deprecated. Returns the content type passed by the browser or null if not defined. |
java.lang.String |
getFileName()
Deprecated. Returns the original filename in the user's filesystem. |
java.io.InputStream |
getInputStream()
Deprecated. Returns an InputStream that can be
used to retrieve the contents of the file. |
java.lang.String |
getName()
Deprecated. Returns the original filename in the user's filesystem. |
java.io.OutputStream |
getOutputStream()
Deprecated. Returns an OutputStream that can
be used for storing the contents of the file. |
long |
getSize()
Deprecated. Returns the size of the file. |
java.io.File |
getStoreLocation()
Deprecated. Returns the File objects for the FileItems's
data temporary location on the disk. |
java.io.InputStream |
getStream()
Deprecated. Returns an InputStream that can be
used to retrieve the contents of the file. |
java.lang.String |
getString()
Deprecated. Returns the contents of the file as a String, using default encoding. |
java.lang.String |
getString(java.lang.String encoding)
Deprecated. Returns the contents of the file as a String, using specified encoding. |
boolean |
inMemory()
Deprecated. Provides a hint if the file contents will be read from memory. |
static FileItem |
newInstance(java.lang.String path,
java.lang.String name,
java.lang.String contentType,
int requestSize)
Deprecated. Instantiates a FileItem. |
void |
write(java.lang.String file)
Deprecated. A convenience method to write an uploaded file to disk. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEFAULT_UPLOAD_SIZE_THRESHOLD
protected java.lang.String fileName
protected java.lang.String contentType
null
if
not defined.
protected byte[] content
protected java.io.File storeLocation
protected java.io.ByteArrayOutputStream byteStream
Constructor Detail |
protected FileItem(java.lang.String fileName, java.lang.String contentType)
FileItem
.
Use newInstance(String,String,String,int)
to
instantiate FileItems
.
fileName
- The original filename in the user's filesystem.contentType
- The content type passed by the browser or
null
if not defined.Method Detail |
public java.lang.String getName()
getName
in interface javax.activation.DataSource
public java.lang.String getFileName()
public java.lang.String getContentType()
null
if not defined. (implements
DataSource method).
getContentType
in interface javax.activation.DataSource
null
if not defined.public boolean inMemory()
True
if the file contents will be read
from memory.public long getSize()
public byte[] get()
public java.lang.String getString()
get()
to retrieve the
contents of the file.
public java.lang.String getString(java.lang.String encoding) throws java.io.UnsupportedEncodingException
get()
to retireve the
contents of the file.
encoding
- The encoding to use.
UnsupportedEncodingException.
java.io.UnsupportedEncodingException
public java.io.InputStream getInputStream() throws java.io.IOException
InputStream
that can be
used to retrieve the contents of the file. (implements DataSource
method)
getInputStream
in interface javax.activation.DataSource
InputStream
that can be
used to retrieve the contents of the file.
Exception,
- a generic exception.
java.io.IOException
public java.io.InputStream getStream() throws java.io.IOException
InputStream
that can be
used to retrieve the contents of the file.
InputStream
that can be
used to retrieve the contents of the file.
Exception,
- a generic exception.
java.io.IOException
public java.io.File getStoreLocation()
File
objects for the FileItems's
data temporary location on the disk. Note that for
FileItems
that have their data stored in memory
this method will return null
. When handling large
files, you can use File.renameTo(File)
to
move the file to new location without copying the data, if the
source and destination locations reside within the same logical
volume.
protected void finalize()
public java.io.OutputStream getOutputStream() throws java.io.IOException
OutputStream
that can
be used for storing the contents of the file.
(implements DataSource method)
getOutputStream
in interface javax.activation.DataSource
OutputStream
that can be
used for storing the contensts of the file.
IOException.
java.io.IOException
public static FileItem newInstance(java.lang.String path, java.lang.String name, java.lang.String contentType, int requestSize)
requestSize
to
decide what temporary storage approach the new item should
take. The largest request that will have its items cached in
memory can be configured in
TurbineResources.properties
in the entry named
file.upload.size.threshold
path
- A String.name
- The original filename in the user's filesystem.contentType
- The content type passed by the browser or
null
if not defined.requestSize
- The total size of the POST request this item
belongs to.
public void write(java.lang.String file) throws java.lang.Exception
java.lang.Exception
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |