npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

com.panin.cordova.plugin.sftp

v1.3.0

Published

Cordova SFTP Upload And Download

Downloads

2

Readme

SFTP Upload/Download Plugin

Cordova plugin to Download and Upload files from a SFTP server.

This plugin is build on top of:

  • JSch library for Android.
  • NMSSH framework for iOS.

Contributors are welcome.

Platforms supported

  • Android
  • iOS (Partial)

Installation

cordova plugin add cordova-sftp-plugin

Easy Use

There is a base Object JJsftp expose in window that should be initialized with the host, user and password for the server

var mySftp = new JJsftp("host", "user", "password");

Methods

  • download(serverPath, localPath [, createIfNotExists, successCallback, errorCallback]) Allow to download a single file.
    • serverPath - Path/To/File/In/Server
    • localPath - Path/To/File/In/Device
    • createIfNotExists - Create the folder path if not exist
    • successCallback - Function to call in plugin success
    • errorCallback - Function to call in plugin error
  • downloadList(list [, successCallback, errorCallback]) Allow to download a list of files
    • list - Object array of files, has the follow attributes:
      • remote - Path/To/File/In/Server
      • local - Local/Path/To/File
      • [create] - default to: false - Create the folder path if not exist
    • successCallback - Function to call in plugin success
    • errorCallback - Function to call in plugin error
  • upload(serverPath, localPath [, successCallback, errorCallback]) Allow to download a single file.
    • serverPath - Path/To/File/In/Server
    • localPath - Path/To/File/In/Device
    • successCallback - Function to call in plugin success
    • errorCallback - Function to call in plugin error
  • uploadList(list [, successCallback, errorCallback]) Allow to download a list of files
    • list - Object array of files, has the follow attributes
      • remote - Path/To/File/In/Server
      • local - Local/Path/To/Fil
    • successCallback - Function to call in plugin success
    • errorCallback - Function to call in plugin error
  • cancel([successCallback, errorCallback]) Allow to cancel the asyn process that make the connection
    • successCallback - Function to call in plugin success
    • errorCallback - Function to call in plugin error
Important

Every callback (success or error) will response for the action of add the elements downloads/upload list, if you wanna know when a file or all the files are donwloaded, you should listen to the events fires over document.

Events

There are several events that fire during the process, all of it give one arg, the cordova event with few extra attributes

  • SFTPActionConnected
    • Desc: Fire on sftp channel connect
    • Extra event attributes: none
  • SFTPActionStart
    • Desc: Fire when an action is about to start in a file
    • Extra event attributes:
      • from- string : Path of the source
      • to - string : Path of the target
      • size - long : Size of the element
  • SFTPActionProgress
    • Desc: fire to inform the % of down/up load in the ACTUAL file
    • Extra event attributes:
      • percent - int : % of actual file progress
  • SFTPActionEnd
    • Desc: fire whe the ACTUAL action over a file end
    • Extra event attributes: none
  • SFTPActionListProgress
    • Desc: Fire after an action (Up/Down) is executed over a file, giving the actual file (index in list) and total files in list
    • Extra event attributes:
      • progress - int : Actual element index in list
      • total - int : Total count of elements in list
  • SFTPActionListEnd
    • Desc: Fire at end of action list to inform the # of file rech it
    • Extra event attributes:
      • all - boolean : true if all action were made it
  • SFTPActionDisconnected
    • Desc: Fire on sftp channel disconnect
    • Extra event attributes: none
  • SFTPActionCancell
    • Desc: Fire on cancel async action
    • Extra event attributes: none

Use Example

To Download

var sftp        = new JJsftp("host", "user", "password"),
    localPath   = "String/Path/To/Place/The/Download"
    filelist    = [{
          remote    : "/Path/To/Remote/File.*"
        , local     : localPath+"file.*"
    },{
          remote    : "/Path/To/Another/Remote/File.*"
        , local     : localPath+"anotherFile.*"
    }];

    sftp.downloadList(filelist, function(data){
        /* Wow everything goes good, but just in case verify data.success */
    }, function(error){
        /* Wow something goes wrong, check the error.message */       
    });

To Upload is the same but calling upload or uploadList and by default will override a file if exists in server

Of course if you want, you could add any of the JJsftp events to document and listen the progress of the download by example

#### Know Issues

  • upload does not work on iOS (Yet)
  • cancel does not work on iOS (Yet), therefore SFTPActionCancell is never trigger.

There is a big TODO list, but in resume

  • Bug Resolve =>
    • No Connection Break The App (Should The plugin warning the user or just don't do anything)
    • ~~Only receive the absolute platfomr path (Without file://), should be replace in plugin don't force the user to replace it~~
    • Events just send a simple string object, need to be parse by user, should be the as many as need witouth the need to parse it
  • Write a better documentation
  • Propose new utils features (I think maybe in a fetch directory will be util) without lose the perspective of the plugin (Upload - Download via SFTP)
  • Add iOS Support (Be Patient) (Partial done, download now available)
  • Improve Uploading and Downloading feature