com.filenet.wcm.toolkit.server.util
Class WcmUploadInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended byjava.io.FilterInputStream
          extended bycom.filenet.wcm.api.impl.SerializableTransportInputStream
              extended bycom.filenet.wcm.api.TransportInputStream
                  extended bycom.filenet.wcm.toolkit.server.util.WcmUploadInputStream
All Implemented Interfaces:
java.io.Serializable

public class WcmUploadInputStream
extends com.filenet.wcm.api.TransportInputStream

WcmUploadInputStream provides temporary caching of files found in a MIME encoded request body, presenting such a file as an InputStream.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.filenet.wcm.api.impl.SerializableTransportInputStream
com.filenet.wcm.api.impl.SerializableTransportInputStream.RetrievalInputStream
 
Field Summary
 
Fields inherited from class com.filenet.wcm.api.TransportInputStream
CONTENT_SIZE_UNKNOWN
 
Fields inherited from class java.io.FilterInputStream
in
 
Method Summary
 void close()
          Close this input stream.
 long getContentSize()
          Get the length in bytes of the file content.
 java.lang.String getFilename()
          Returns the original filename as specified by the user in the browser.
static WcmUploadInputStream getInstance(WcmDataStore ds, java.io.BufferedReader buff, javax.servlet.http.HttpServletRequest req, java.lang.String fileName)
          The constructor for WcmUploadInputStream.
static WcmUploadInputStream getInstance(WcmDataStore ds, javax.servlet.http.HttpServletRequest req, java.lang.String inputName)
          The constructor for WcmUploadInputStream.
static WcmUploadInputStream getInstance(WcmDataStore ds, WcmMimeFormParser mfp, javax.servlet.http.HttpServletRequest req)
          The constructor for WcmUploadInputStream.
 java.lang.String getMimeType()
          Returns the mime type of the uploaded file.
 java.lang.String getTempFileName()
          Returns the name of the temporary cache file where the content is being stored on the web server.
 boolean isOpen()
          Returns true/false whether or not this input stream is currently open for reading.
 boolean isValid()
          Returns true/false whether or not the requested file content was found in the ServletInputStream of HttpServletRequest.
 
Methods inherited from class com.filenet.wcm.api.TransportInputStream
getContentElement, getContentStream, getElementSequenceNumber, setContentElement, setContentSize, setFilename, setMimeType
 
Methods inherited from class java.io.FilterInputStream
available, mark, markSupported, read, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static WcmUploadInputStream getInstance(WcmDataStore ds,
                                               javax.servlet.http.HttpServletRequest req,
                                               java.lang.String inputName)
                                        throws java.io.IOException
The constructor for WcmUploadInputStream. Reads the multipart/form-data encoded input stream from HttpServletRequest, finds the file content, caches it locally, and serves it up as an input stream that can be sent to the Content Java API.

Use close() when finished, and the cache file will be automatically deleted.

Parameters:
ds - An instance of WcmDataStore.
req - The current HttpServletRequest.
inputName - The form input name corresponding to the file you want to cache/open (optional). If null is specified, the first file encountered in the ServletInputStream will be cached.
Throws:
java.io.IOException

getInstance

public static WcmUploadInputStream getInstance(WcmDataStore ds,
                                               WcmMimeFormParser mfp,
                                               javax.servlet.http.HttpServletRequest req)
                                        throws java.io.IOException
The constructor for WcmUploadInputStream. Reads the multipart/form-data encoded input stream from HttpServletRequest, finds the file content, caches it locally, and serves it up as an input stream that can be sent to the Content Java API.

Use close() when finished, and the cache file will be automatically deleted.

Parameters:
ds - An instance of WcmDataStore.
mfp - The WcmMimeFormParser to load from.
Returns:
null if the current item is not a file.
Throws:
java.io.IOException

getInstance

public static WcmUploadInputStream getInstance(WcmDataStore ds,
                                               java.io.BufferedReader buff,
                                               javax.servlet.http.HttpServletRequest req,
                                               java.lang.String fileName)
                                        throws java.io.IOException
The constructor for WcmUploadInputStream. Reads the multipart/form-data encoded input stream from HttpServletRequest, finds the file content, caches it locally, and serves it up as an input stream that can be sent to the Content Java API.

Use close() when finished, and the cache file will be automatically deleted.

Parameters:
ds -
buff -
req -
fileName -
Returns:
Throws:
java.io.IOException

getContentSize

public long getContentSize()
Get the length in bytes of the file content.

Returns:
int.

getMimeType

public java.lang.String getMimeType()
Returns the mime type of the uploaded file.

Returns:
String

getFilename

public java.lang.String getFilename()
Returns the original filename as specified by the user in the browser.

Returns:
String.

getTempFileName

public java.lang.String getTempFileName()
Returns the name of the temporary cache file where the content is being stored on the web server.

Returns:
String

isValid

public boolean isValid()
Returns true/false whether or not the requested file content was found in the ServletInputStream of HttpServletRequest.

Returns:
boolean true/false.

isOpen

public boolean isOpen()
Returns true/false whether or not this input stream is currently open for reading. If isOpen returns true, it also means that the requested file content was found in the ServletInputStream of HttpServletRequest (isValid will return true).

Returns:
boolean true/false.

close

public void close()
           throws java.io.IOException
Close this input stream. The cache file is automatically deleted.

Throws:
java.io.IOException


© Copyright IBM Corp. 2002, 2007. All Rights Reserved.