Fwd: Downloading Files
Michael Deninger <[email protected]>
| Newsgroups | gmane.comp.web.webobjects.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I have created (successfully) in implementation of a WOFileUpload and
a corresponding file download component based on info on the various
list serves. These work as advertised (with a few gotchas, of
course). My problem is when downloading the file stored in the
database. Specifically, the name of the file.
When I upload the file on a Mac (Safari) the file name is
successfully grabbed and stored in the DB along with the Data. Using
Windows and IE6, I have to manually parse the filename to eliminate
the "c:\DOS\Crap\Path\" from the filename. Again, no problem (though
annoying).
On download (Mac and Safari) things work as expected. Win IE 6,
however, does not populate the filename from the download link.
Instead, the file is named based on the number.number.number.etc
internal url created by WO. The file successfully downloads and will
open when the name (including the extension) is manually added.
In a nutshell, is there some header (that I have missed) that can
pass the filename upon download to IE 6? Below is the generic code
for the download component called from the hyperlink (taken almost
exactly as it appears on this list earlier)...
Regards,
Mike
import com.webobjects.foundation.*;
import com.webobjects.appserver.*;
import com.webobjects.eocontrol.*;
import com.webobjects.eoaccess.*;
public class FileDownload extends WOComponent {
protected UploadedDocument soapFile;
protected String mimeType;
public FileDownload(WOContext context) {
super(context);
// mime type default
mimeType = "application/octet-stream";
}
public void appendToResponse(WOResponse response, WOContext
context) {
response.setHeader(mimeType, "content-type");
response.setHeader("attachment; filename=" +
soapFile.fileName(), "content-disposition");
response.setHeader(new Long( soapFile.fileData().length
() ).toString(), "content-length");
response.setContent(soapFile.fileData());
// super.appendToResponse(response,context);
}
public UploadedDocument soapFile()
{
return soapFile;
}
public void setSoapFile(UploadedDocument newFile)
{
soapFile = newFile;
}
}
_______________________________________________
WebObjects-dev mailing list
[email protected]
http://www.omnigroup.com/mailman/listinfo/webobjects-dev