com.sapportals.wcm.util.mmparser

Class FilePart

java.lang.Object
  extended bycom.sapportals.wcm.util.mmparser.AbstractPart
      extended bycom.sapportals.wcm.util.mmparser.FilePart

public class FilePart
extends AbstractPart

A FilePart is an upload part which represents a INPUT TYPE="file" form parameter.


Method Summary
 String getFileName()
          Returns the name that the file was stored with on the remote system, or null if the user didn't enter a file to be uploaded.
 HeaderFields getHeader()
          
 InputStream getInputStream()
          Returns an input stream which contains the contents of the file supplied.
 boolean isFile()
          Returns true to indicate this part is a file.
 void setHeader(HeaderFields header)
          
protected  long write(OutputStream out)
          Internal method to write this file part; doesn't check to see if it has contents first.
 long writeTo(File fileOrDirectory)
          Write this file part to a file or directory.
 long writeTo(OutputStream out)
          Write this file part to the given output stream.
 
Methods inherited from class com.sapportals.wcm.util.mmparser.AbstractPart
getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFileName

public String getFileName()
Returns the name that the file was stored with on the remote system, or null if the user didn't enter a file to be uploaded. Note: this is not the same as the name of the form parameter used to transmit the file; that is available from the getName method.

Returns:
name of file uploaded or null .

getHeader

public HeaderFields getHeader()

Returns:

setHeader

public void setHeader(HeaderFields header)

Parameters:
header -

getInputStream

public InputStream getInputStream()
Returns an input stream which contains the contents of the file supplied. If the user didn't enter a file to upload there will be 0 bytes in the input stream.

Returns:
an input stream containing contents of file.

writeTo

public long writeTo(File fileOrDirectory)
             throws IOException
Write this file part to a file or directory. If the user supplied a file, we write it to that file, and if they supplied a directory, we write it to that directory with the filename that accompanied it. If this part doesn't contain a file this method does nothing.

Parameters:
fileOrDirectory -
Returns:
number of bytes written
Throws:
IOException -

writeTo

public long writeTo(OutputStream out)
             throws IOException
Write this file part to the given output stream. If this part doesn't contain a file this method does nothing.

Parameters:
out -
Returns:
number of bytes written.
Throws:
IOException -

isFile

public boolean isFile()
Returns true to indicate this part is a file.

Overrides:
isFile in class AbstractPart
Returns:
true.

write

protected long write(OutputStream out)
              throws IOException
Internal method to write this file part; doesn't check to see if it has contents first.

Parameters:
out -
Returns:
number of bytes written.
Throws:
IOException - if an input or output exception has occurred.


Copyright 2006 SAP AG Complete Copyright Notice