Re: ftp upload

Mike Lee <[email protected]> Tue, 19 Nov 2002 06:25:34 +1100
Newsgroups gmane.comp.mozilla.devel.xpcom
Organization Another Netscape Collabra Server User
Message-ID <[email protected]>
It should work (works for me at least ;)), what mozilla build are you 
using? Necko folks are still changing apis might be broken in the 1.2+. 
Since I'm using 1.1 I'm waiting for 1.2b before I update it.

Regards

Gilles Durys wrote:
 > I'm trying to upload a file to a ftp server with the following code
 > (modified from mozblog).
 >
 > function uploadFile() { var ioService =
 > Components.classes["@mozilla.org/network/io-service;1"]
 > .getService(Components.interfaces.nsIIOService); var url =
 > Components.classes["@mozilla.org/network/standard-url;1"]; fileurl =
 > url.createInstance(Components.interfaces.nsIURL); fileurl.spec =
 > "file:///home/sco/polom.html";
 >
 > var srcChannel = ioService.newChannelFromURI(fileurl); var remoteUrl
 > = url.createInstance(Components.interfaces.nsIURL); remoteUrl.spec =
 > "ftp://sco:[email protected]/downloads/polom.txt"; var
 > ftpChannel = ioService.newChannelFromURI(remoteUrl)
 > .QueryInterface(Components.interfaces.nsIUploadChannel);  var
 > bufferedStream =
 > Components.classes["@mozilla.org/network/buffered-input-stream;1"]
 > .createInstance(Components.interfaces.nsIBufferedInputStream);
 > bufferedStream.init(srcChannel.open(), srcChannel.contentLength);
 > ftpChannel.setUploadStream(bufferedStream,null,-1);
 > ftpChannel.asyncOpen(myListener(), null); }
 >
 > Calling that function gives me the following error:
 >
 > uncaught exception: [Exception... "Component returned failure code:
 > 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIChannel.open]"  nsresult:
 > "0x8000ffff (NS_ERROR_UNEXPECTED)"  location: "JS frame ::
 > uploadPic.js :: uploadFile :: line 15"  data: no]
 >
 >
 > I'm a little lost there, so any help/hint/lead is welcome.
 >


-- 
Mike Lee
Website: http://www.exitspace.net/mike