I'm trying to get some code that allows saving of some data
(http/ftp/file URLs) and it works for nsIHttpChannel and nsIFtpChannel
but nsIFileChannel doesn't seem to like it. I get no file created and an
error of 0x8000ffff.
Here's the code:
var dataString = "This is a test string\n";
var ioService = Components.classes[
"@mozilla.org/network/io-service;1"
].getService(Components.interfaces.nsIIOService);
var nsIURI Components.classes[
"@mozilla.org/network/standard-url;1"
].createInstance(Components.interfaces.nsIURI);
nsIURI.spec = "file:///tmp/test.file";
var ioChannel = ioService.newChannelFromURI(nsIURI);
var destChannel = ioChannel.QueryInterface(
Components.interfaces.nsIFileChannel
);
var uploadChannel = destChannel.QueryInterface(
Components.interfaces.nsIUploadChannel
);
var postStream = Components.classes[
"@mozilla.org/io/string-input-stream;1"
].createInstance(Components.interfaces.nsIStringInputStream);
postStream.setData(dataString, dataString.length);
uploadChannel.setUploadStream(postStream, "text/plain", -1);
uploadChannel.asyncOpen(listener, null);
Thank you for any help.
Matthew Buckett
- Re: nsIUploadChannel and nsIFileChannel Matthew Buckett
- Re: nsIUploadChannel and nsIFileChannel Boris Zbarsky
