| versions | 0095+ |
|---|---|
| contributors | markhill |
| started on | 2006-03-21 08:31 |
Under development…
ftp can be easily integrated into your sketches using edtftpj.
Link to Watz warning of denial of service attack in forum Link to an ftp guidleines page
This is the Processing equivalent of the out-of-the-box demo supplied with edtftpj. Working with threads means you can have a ftp system running alongside your sketch to avoid having to wait for ftp tasks to complete.
/** ftp taken from http://processinghacks.com/hacks:ftp @author Mark Hill */ FTPClient ftp; // Populate these variables with the necessary info. String host = ""; String username = ""; String password = ""; String remotePath = "" String localPath = ""; void setup () { try { // set up client ftp = new FTPClient(); ftp.setRemoteHost(host); FTPMessageCollector listener = new FTPMessageCollector(); ftp.setMessageListener(listener); // connect println ("Connecting"); ftp.connect(); // login println ("Logging in"); ftp.login(username, password); // set up passive ASCII transfers println ("Setting up passive, ASCII transfers"); ftp.setConnectMode(FTPConnectMode.PASV); ftp.setType(FTPTransferType.ASCII); // get directory and print it to console println ("Directory before put:"); String[] files = ftp.dir(".", true); for (int i = 0; i < files.length; i++) println (files[i]); // copy file to server println ("Putting file"); ftp.put("/localPath/test.txt", "/remotePath/test.txt"); // get directory and print it to console println ("Directory after put"); files = ftp.dir(".", true); for (int i = 0; i < files.length; i++) println (files[i]); // copy file from server println ("Getting file"); ftp.get("/localPath/test.txt" + ".copy", "/remotePath/test.txt"); // delete file from server println ("Deleting file"); ftp.delete("/remotePath/test.txt"); // get directory and print it to console println ("Directory after delete"); files = ftp.dir("", true); for (int i = 0; i < files.length; i++) println (files[i]); // Shut down client println ("Quitting client"); ftp.quit(); String messages = listener.getLog(); println ("Listener log:"); println(messages); println ("Test complete"); } catch (Exception e) { println ("Demo failed"); } } }
You'll need to upload the zipped sketchfolder of your hack, in order to offer it as download. The wiki has an upload button in the editor toolbar (2nd last on the right). Please choose the “hacks” namespace as target…