org.apache.tapestry.multipart
Class UploadPart

java.lang.Object
  extended by org.apache.tapestry.multipart.UploadPart
All Implemented Interfaces:
IPart, IUploadFile

public class UploadPart
extends Object
implements IUploadFile, IPart

Portion of a multi-part request representing an uploaded file.

Since:
2.0.1
Version:
$Id: UploadPart.java 243791 2004-02-19 17:38:13Z hlship $
Author:
Joe Panico

Constructor Summary
UploadPart(org.apache.commons.fileupload.FileItem fileItem)
           
 
Method Summary
 void cleanup()
          Deletes the external content file, if one exists.
 String getContentType()
          Returns the MIME type specified when the file was uploaded.
 String getFileName()
          Leverages File to convert the full file path and extract the name.
 String getFilePath()
          Returns the complete path, as reported by the client browser.
 long getSize()
          Returns the size, in bytes, of the uploaded content.
 InputStream getStream()
          Returns an input stream of the content of the file.
 boolean isInMemory()
          Returns true if the uploaded content is in memory.
 void write(File file)
          Writes the uploaded content to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UploadPart

public UploadPart(org.apache.commons.fileupload.FileItem fileItem)
Method Detail

getContentType

public String getContentType()
Description copied from interface: IUploadFile
Returns the MIME type specified when the file was uploaded. May return null if the content type is not known.

Specified by:
getContentType in interface IUploadFile

getFileName

public String getFileName()
Leverages File to convert the full file path and extract the name.

Specified by:
getFileName in interface IUploadFile

getFilePath

public String getFilePath()
Description copied from interface: IUploadFile
Returns the complete path, as reported by the client browser. Different browsers report different things here.

Specified by:
getFilePath in interface IUploadFile
Since:
2.0.4

getStream

public InputStream getStream()
Description copied from interface: IUploadFile
Returns an input stream of the content of the file. There is no guarantee that this stream will be valid after the end of the current request cycle, so it should be processed immediately.

As of release 1.0.8, this will be a a ByteArrayInputStream, but that, too, may change (a future implementation may upload the stream to a temporary file and return an input stream from that).

Specified by:
getStream in interface IUploadFile

cleanup

public void cleanup()
Deletes the external content file, if one exists.

Specified by:
cleanup in interface IPart
See Also:
cleanup()

write

public void write(File file)
Writes the uploaded content to a file. This should be invoked at most once (perhaps we should add a check for this). This will often be a simple file rename.

Specified by:
write in interface IUploadFile
Since:
3.0

getSize

public long getSize()
Description copied from interface: IUploadFile
Returns the size, in bytes, of the uploaded content.

Specified by:
getSize in interface IUploadFile
Since:
3.0

isInMemory

public boolean isInMemory()
Description copied from interface: IUploadFile
Returns true if the uploaded content is in memory. False generally means the content is stored in a temporary file.

Specified by:
isInMemory in interface IUploadFile
Since:
3.0