org.directwebremoting.io
Class FileTransfer

java.lang.Object
  extended by org.directwebremoting.io.FileTransfer

public class FileTransfer
extends java.lang.Object

One of the 2 ways you can receive uploaded files from a DWR enabled page is to expose a method with a FileTransfer parameter. The other is to expose a method with an InputStream parameter.

Author:
Lance Semmens [uklance at gmail dot com], Joe Walker [joe at getahead dot ltd dot uk], Niklas Johansson [niklas dot json at gmail dot com]

Constructor Summary
FileTransfer(java.awt.image.BufferedImage image, java.lang.String type)
          A ctor for the 3 things browsers tell us about the uploaded file
FileTransfer(java.awt.image.BufferedImage image, java.lang.String filename, java.lang.String type)
          A ctor for the 3 things browsers tell us about the uploaded file
FileTransfer(java.lang.String filename, java.lang.String mimeType, byte[] bytes)
          A ctor for the 3 things browsers tell us about the uploaded file
FileTransfer(java.lang.String filename, java.lang.String mimeType, java.io.InputStream in)
          A ctor for the 3 things browsers tell us about the uploaded file
FileTransfer(java.lang.String filename, java.lang.String mimeType, InputStreamFactory inputStreamFactory)
          A ctor for the 3 things browsers tell us about the uploaded file
FileTransfer(java.lang.String filename, java.lang.String mimeType, long size, java.io.InputStream in)
          A ctor for InputStream + all other details
FileTransfer(java.lang.String filename, java.lang.String mimeType, long size, InputStreamFactory inputStreamFactory)
          A ctor for InputStreamFactory + all other details
FileTransfer(java.lang.String filename, java.lang.String mimeType, OutputStreamLoader outputStreamLoader)
          A ctor for the 3 things browsers tell us about the uploaded file
 
Method Summary
 java.lang.String getFilename()
          Returns the original filename in the client's file-system, as provided by the browser (or other client software).
 java.io.InputStream getInputStream()
          Returns an InputStream that can be used to retrieve the contents of the file.
 java.lang.String getMimeType()
          Returns the content type passed by the browser or null if not defined.
 OutputStreamLoader getOutputStreamLoader()
          Returns an OutputStreamLoader that can be used to retrieve the contents of the file.
 long getSize()
          Returns the size of the file passed by the browser or -1 if this is not known.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileTransfer

public FileTransfer(java.lang.String filename,
                    java.lang.String mimeType,
                    OutputStreamLoader outputStreamLoader)
A ctor for the 3 things browsers tell us about the uploaded file

Parameters:
filename - The remote source filename
mimeType - The mime type passed in by the browser
outputStreamLoader - A means by which the data can be read

FileTransfer

public FileTransfer(java.awt.image.BufferedImage image,
                    java.lang.String type)
A ctor for the 3 things browsers tell us about the uploaded file


FileTransfer

public FileTransfer(java.awt.image.BufferedImage image,
                    java.lang.String filename,
                    java.lang.String type)
A ctor for the 3 things browsers tell us about the uploaded file


FileTransfer

public FileTransfer(java.lang.String filename,
                    java.lang.String mimeType,
                    byte[] bytes)
A ctor for the 3 things browsers tell us about the uploaded file

Parameters:
filename - The remote source filename
mimeType - The mime type passed in by the browser
bytes - the raw data

FileTransfer

public FileTransfer(java.lang.String filename,
                    java.lang.String mimeType,
                    long size,
                    InputStreamFactory inputStreamFactory)
A ctor for InputStreamFactory + all other details

Parameters:
filename - The remote source filename
mimeType - The mime type passed in by the browser
size - The size of the file
inputStreamFactory - A means by which the data can be read

FileTransfer

public FileTransfer(java.lang.String filename,
                    java.lang.String mimeType,
                    long size,
                    java.io.InputStream in)
A ctor for InputStream + all other details

Parameters:
filename - The remote source filename
mimeType - The mime type passed in by the browser
size - The size of the file
in - A means by which the data can be read.

FileTransfer

public FileTransfer(java.lang.String filename,
                    java.lang.String mimeType,
                    InputStreamFactory inputStreamFactory)
A ctor for the 3 things browsers tell us about the uploaded file

Parameters:
filename - The remote source filename
mimeType - The mime type passed in by the browser
inputStreamFactory - A means by which the data can be read

FileTransfer

public FileTransfer(java.lang.String filename,
                    java.lang.String mimeType,
                    java.io.InputStream in)
A ctor for the 3 things browsers tell us about the uploaded file

Parameters:
filename - The remote source filename
mimeType - The mime type passed in by the browser
in - A means by which the data can be read.
Method Detail

getFilename

public java.lang.String getFilename()
Returns the original filename in the client's file-system, as provided by the browser (or other client software). In most cases, this will be the base file name, without path information. However, some clients, such as the Opera browser, do include path information.

Returns:
The original filename in the client's file-system.

getMimeType

public java.lang.String getMimeType()
Returns the content type passed by the browser or null if not defined.


getSize

public long getSize()
Returns the size of the file passed by the browser or -1 if this is not known.


getOutputStreamLoader

public OutputStreamLoader getOutputStreamLoader()
Returns an OutputStreamLoader that can be used to retrieve the contents of the file.


getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Returns an InputStream that can be used to retrieve the contents of the file. InputStreamFactory is used place of direct access to an InputStream to ensure that resources are properly closed.

Throws:
java.io.IOException

Copyright 2008