public class FileDownloadProvider extends Object implements nextapp.echo2.app.filetransfer.DownloadProvider
The following shows sample usage of this class:
import nextapp.echo2.app.filetransfer.Download;
import com.sptci.echo2.FileDownloadProvider;
...
File file = new File( "/tmp/test.java" );
FileDownloadProvider provider =
new FileDownloadProvider( file, "application/x-download" );
Download download = new Download();
download.setProvider( provider );
download.setActive( true );
Application.getActive().enqueueCommand( download );
Copyright 2006 Sans Pareil Technologies, Inc.
| Constructor and Description |
|---|
FileDownloadProvider(File file,
String contentType)
Create a new instance of the provider for the specified file.
|
FileDownloadProvider(String file,
String contentType)
Create a new instance of the provider for the specified file.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
fileExists()
Return true if the
file points to a valid file. |
String |
getContentDisposition()
Returns the
content-disposition for the file. |
String |
getContentType()
Returns the content type of the file.
|
String |
getFileName()
Returns the file's name.
|
String |
getPath()
Returns the file's fully qualified path.
|
int |
getSize()
Returns the size of the file.
|
void |
writeFile(OutputStream out)
Writes the file to the specified output stream.
|
public FileDownloadProvider(String file, String contentType)
file - The file to use.contentType - The contentType to use.public FileDownloadProvider(File file, String contentType)
file - The file to use.contentType - The contentType to use.public String getContentType()
getContentType in interface nextapp.echo2.app.filetransfer.DownloadProviderpublic String getContentDisposition()
content-disposition for the file. Mandatory
method introduced in patched version of file transfer library. Sets
to inline to force browser to display if possible.getContentDisposition in interface nextapp.echo2.app.filetransfer.DownloadProviderpublic String getFileName()
getFileName in interface nextapp.echo2.app.filetransfer.DownloadProviderpublic String getPath()
public int getSize()
getSize in interface nextapp.echo2.app.filetransfer.DownloadProviderpublic boolean fileExists()
file points to a valid file.true if the file exists.public void writeFile(OutputStream out) throws IOException
writeFile in interface nextapp.echo2.app.filetransfer.DownloadProviderout - The output stream to which the file should be written.IOException - If the provider is unable to perform this operation.