🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

react-native-ftp-client

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-ftp-client

FTP client library for android and ios

1.1.6
latest
npm
Version published
Weekly downloads
1
-75%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-ftp-client

A ftp client library for react native Thanks for react-native-ftp. Get inspired from it, but almost rewrite every corner.

  • support three operations

    • list ftp dir.
    • upload file to ftp.
    • download file from ftp.
    • remove file or dir from ftp.
  • NO session, which means treating each operation as a session.
    Therefore, it is easier to use for javascript client even introduce some overhead on login and logout.

Limit

the download operation depends on the ftp server support size cmd

Example

const downloadFileFrom = async (ftpHost, remote_file_path) => {
    FTP.setup({
      ip_address: ftpHost,
      port: 21,
      username: 'anonymous',
      password: 'guest',
    }); //Setup host

    const localPath = 'local file path';

    try {
      let currentToken = '';
      const subscription = FTP.addProgressListener(({token, percentage}) => {
        if (percentage === 0) {
            //record token
            currentToken = token;
        }
        if (token !== currentToken) {
            //ignore
        } else {
            //show percentage. it is a integer
            if (percentage >= 100) {
                //finish download
            }
        }
      });
      await FTP.downloadFile(localPath, remote_file_path);
      //continue after download finish
    } catch (error) {
        if(error.message === FTP.ERROR_MESSAGE_CANCELLED){
            //the download is cancelled
        }
        //other error
    }
  };

Keywords

react-native

FAQs

Package last updated on 18 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts