ftp
mtwin.net.Ftp class
This class handles connections to FTP servers.
Simple example
import mtwin.net.Ftp; ... var ftp = new Ftp(hostName, portNumber); ftp.login(userName, password); neko.Lib.prinln(ftp.pwd()); ftp.cwd("uploads"); ftp.createDirectory("temp"); ftp.cwd("temp"); var file = neko.io.File.read("toUpload.dat", true); ftp.put(file, "newName.dat"); file.close(); file = neko.io.File.write("downloaded.dat", true); ftp.get(file, "newName.dat"); file.close(); ftp.close();
Streams
The FTP class contains two methods which mirror the neko.io.File.read/neko.io.File.write methods. FTP read and write open a new ftp connection dedicated to reading or writing from/to a file. Theses methods returns a neko.io.Input or neko.io.Ouput which must be closed when the operation is completed.
Streams example
var ftp = new Ftp("ftp.foo.com"); ftp.login(); // anonymous var dst = new Ftp("my.ftp.com"); dst.login("foo", "secret"); dst.cwd("uploads"); // copy one file to another ftp var inp = ftp.read("myFile.dat"); var out = dst.write("myFile.dat"); out.writeInput(inp); out.close(); inp.close(); var inp = ftp.read("myFile.dat"); ftp.close(); // 'inp' has its own connection var out = neko.io.File.write("down.dat"); out.writeInput(inp); out.writeInput(new neko.io.StringInput(myOtherDataStringToConcatenate)); out.close(); inp.close(); dst.close();
version #7398, modified 2009-12-24 23:13:11 by tong