For saving locally via an HTTP/S stream, in the onload event of my httpRequest I had been:
var nsIFile = nsIFileProtocolHandler.getFileFromURLSpec("file://..");
nsIFileOutputStream.init( nsIFile, 0x04 | 0x08 | 0x20, 420, 0 );
var lRet = nsIFileOutputStream.write( httpRequest.responseText,
httpRequest.responseText.length );In retrospect this is silly as although it works, this is only via the internal buffer, and I need a mechanism for saving larger files, and so need a way to intercept and write the stream as it arrives.
For opening remote files I had hoped to replace the mechanism I use for local files with one common one:
var nsIFile = nsIFileProtocolHandler.getFileFromURLSpec("file://..");
nsIFile.QueryInterface(Components.interfaces.nsILocalFile);
nsIFile.launch();To the mechanism it looks like Firefox uses:
var nsIFile = nsIFileProtocolHandler.getFileFromURLSpec("file://..");
var type = nsIMIMEService.getTypeFromFile( nsIFile );
var nsIMIMEInfo = nsIMIMEService.getFromTypeAndExtension( type,null );
nsIMIMEInfo.launchWithFile(nsIFile);But this only works on files with a file:// URI.
What mechanism should I pick to allow me to save a remote HTTP/S stream to an nsILocalFile, and do I need to save to a temp file first to open with the default MIME handler or if there a mechanism that'll achieve this for me?
As ever thanks for the help.
Neil
_______________________________________________ Mozilla-netlib mailing list [email protected] http://mail.mozilla.org/listinfo/mozilla-netlib
