项目作者: mwthinker

项目描述 :
A ftp client implemented as a cordova plugin for android.
高级语言: Java
项目地址: git://github.com/mwthinker/FtpClient.git
创建时间: 2015-05-07T17:48:45Z
项目社区:https://github.com/mwthinker/FtpClient

开源协议:MIT License

下载


FtpClient - A cordova plugin for android

A ftp client implemented as a cordova plugin for android.

Can be used to download/upload a file from/to a server.
Installation of this plugin gives the appliction permission to save/load files to/from disc.

License

Is under the MIT license, see LICENSE.TXT.

Installation

  1. $ cd MyCordovaProject
  2. $ cordova plugin add https://github.com/mwthinker/FtpClient.git

Uninstallation

  1. $ cd MyCordovaProject
  2. $ cordova plugin remove se.mwthinker.ftpclient

Javascript API

  1. /**
  2. * Upload a file to a FTP server.
  3. *
  4. * @param file The file to be uploaded to the ftp server.
  5. * @param url The url for the ftp server.
  6. * @param success The success callback.
  7. * @param failure The failure callback.
  8. */
  9. function upload(file, url, success, failure);
  10. /**
  11. * Download an ascii file from a FTP server.
  12. *
  13. * @param file The ascii file to be downloaded from the ftp server.
  14. * @param url The url for the ftp server.
  15. * @param success The success callback.
  16. * @param failure The failure callback.
  17. */
  18. function downloadAsciiFile(file, url, success, failure);
  19. /**
  20. * Download a binary file from a FTP server.
  21. *
  22. * @param file The binary file to be downloaded from the ftp server.
  23. * @param url The url for the ftp server.
  24. * @param success The success callback.
  25. * @param failure The failure callback.
  26. */
  27. function downloadBinaryFile(file, url, success, failure);
  28. /**
  29. * Download an ascii file as an ascii string from a FTP server.
  30. *
  31. * @param url The url for the ftp server.
  32. * @param success The success callback.
  33. * @param failure The failure callback.
  34. */
  35. function downloadAsciiString(url, success, failure);

Usage example

Edit www/js/index.js and add the following code inside onDeviceReady

  1. var success = function(asciiText) {
  2. alert(asciiText); // Whole file is written in the alert message.
  3. }
  4. var failure = function() {
  5. alert("Error calling ftpClient");
  6. }
  7. // Variable ftpClient is defined by the plugin at appliction start up.
  8. ftpClient.downloadAsciiString("ftp://user:password@host:port/path ", success, failure);

Acknowledgment

This plugin was created with help from an older ftp plugin found at http://simonmacdonald.blogspot.se/2011/06/ftp-plugin-for-phonegap-android.html.
Special thanks to its author Simon Mcdonald for providing the guide.

More Info

For more information on setting up Cordova see the documentation.
For more info on plugins see the Plugin Development Guide