项目作者: GMA-Team

项目描述 :
Android SFTP Library
高级语言: Java
项目地址: git://github.com/GMA-Team/ASFLibrary.git
创建时间: 2020-02-12T11:19:58Z
项目社区:https://github.com/GMA-Team/ASFLibrary

开源协议:

下载


ASFLibrary

ASFLibrary is an Android SFTP Library.

Features

  • Upload file to sftp server
  • Get file from stfp server
  • Delete, rename file or directory in sftp server
  • new folder in sftp server
  • Can list file and directory information in sftp server
  • Can set process monitor to do something in every periods when data transferring
  • Can set login result deal function

Usage

At first, you should download source code in you computer throught git, besides, you can use *.arr file which can import to your project through, Android Studio please check release page

  1. mkdir workspace
  2. cd workspace
  3. git clone https://github.com/GMA-Team/ASFLibrary.git

Import

open Android Studio, click

  1. File-New-Import Modules

add this into build.gradle(Module:app) any syc it.

  1. implementation project(path: ':asflibrary')

Quick Start

New a project and add those MainActivity.java. This Activity can login the sftp server and print all file information in directory /home/cpi, of course, you can modify parameters in code according to notes in order to show your directory in your sftp server.

  1. package com.wangtingzheng.gmam;
  2. import android.os.Bundle;
  3. import androidx.appcompat.app.AppCompatActivity;
  4. import com.wangtingzheng.asflibrary.SFTP;
  5. import com.wangtingzheng.asflibrary.Utils.ListResultDealUtils;
  6. import com.wangtingzheng.asflibrary.Utils.LoginDealUtils;
  7. import java.util.Enumeration;
  8. import java.util.Vector;
  9. public class MainActivity extends AppCompatActivity {
  10. @Override
  11. protected void onCreate(Bundle savedInstanceState) {
  12. super.onCreate(savedInstanceState);
  13. setContentView(R.layout.activity_main);
  14. SFTP sftp = new SFTP("cpi", "cpi", "192.168.1.40", 22); //fill with sftp login information
  15. sftp.setLoginDeal(new LoginDealUtils(){ //set login result deal function
  16. @Override
  17. public void dealLoginResult(boolean result){
  18. System.out.println(result);
  19. }
  20. });
  21. sftp.setListResultDeal(new ListResultDealUtils(){ //set list reuslt deal function to print information
  22. @Override
  23. public void dealListResult(Vector<?> result){
  24. Enumeration<?> elements = result.elements();
  25. while (elements.hasMoreElements()) {
  26. System.out.println(elements.nextElement());
  27. }
  28. }
  29. });
  30. sftp.SFTP_List("/home/cpi"); // set the directory and do the action
  31. }
  32. }

More function and features usage can be found in Wiki.

Library