Re: Downloading Files
"Cheong Hee (Datasonic)" <[email protected]>
| Newsgroups | gmane.comp.web.webobjects.devel |
|---|---|
| Message-ID | <008101c6cd6c$972d2c80$6400a8c0@CHNGXP> |
As someone suggested, it has been better to put the response back to the discussion group.
There are additional headers needed to be set for SSL-enabled IE to work. The following are the additional code to add in your appendToResponse:
//this is to overcome caching problem in IE + SSL + downloading file.
//disable caching and remove two keys as shown below.
aResponse.disableClientCaching();
aResponse.removeHeadersForKey("Cache-Control");
aResponse.removeHeadersForKey("pragma");
Good luck.
Cheers
Cheong Hee
----- Original Message -----
From: Michael Deninger
To: Cheong Hee ((Datasonic))
Sent: Wednesday, August 30, 2006 8:23 PM
Subject: Re: Downloading Files
my connections are primarily http and https.
Mike
On Aug 30, 2006, at 2:59 AM, Cheong Hee ((Datasonic)) wrote:
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).
It is annoying indeed...and extra effort to make it cross-platform.
On your downloading issue, I do not encounter the same in Linux platform. And cross-checked headers with mine, it looks there is nothing missing. Just a question, do you try to download the file via SSL/IE?
Cheers
Cheong Hee
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
_______________________________________________
WebObjects-dev mailing list
[email protected]
http://www.omnigroup.com/mailman/listinfo/webobjects-dev