B4i Library iNMSSH - SFTP file transfer

Discussion in 'iOS Libraries' started by Erel, Jan 10, 2018.

  1. Erel

    Erel Administrator Staff Member Licensed User

    iNMSSH is based on NMSSH open source library: https://github.com/NMSSH/NMSSH

    It implements the SFTP protocol.
    Usage example:
    Code:
    Private ssh As NMSSH 'Process globals

    'initialize
    ssh.Initialize("ssh")
    'connect
    ssh.Connect("100.222.222.222"22"username")
    Wait For ssh_Connected (success As Boolean)
    If success Then
       
    Log("connected")
       
    'authenticate
       ssh.Authenticate("password")
       
    Wait For ssh_Authorized (success As Boolean)
       
    If success Then
           
    'file transfer operations
           ssh.List("/")
           
    Wait For ssh_ListCompleted (success As Boolean, Folders As List, Files As List)
           
    If success Then
               
    For Each f As SFtpEntry In Files
                   
    Log($"${f.Name}: $DateTime{f.Timestamp}, ${f.Size}"$)
               
    Next
           
    End If
           ssh.DownloadFile(
    "/somefile"File.DirDocuments, "1.txt")
           
    Wait For ssh_DownloadCompleted (success As Boolean)
           
    If success Then
               
    'Log(File.ReadString(File.DirDocuments, "1.txt"))
           End If
           ssh.UploadFile(
    File.DirAssets, "1.bil""/1.bil")
           
    Wait For ssh_UploadCompleted (success As Boolean)
           
    Log("upload: " & success)
           ssh.DeleteFile(
    "/1.bil")
           
    Wait For ssh_DeleteCompleted (success As Boolean)
           
    Log(success)
       
    End If
    End If
    'close when done
    ssh.Close
    There could only be a single NMSSH object.



    Mac builder files: www.b4x.com/b4i/files/iNMSSH.zip
     

    Attached Files:

  2. MarcoRome

    MarcoRome Expert Licensed User

    Weel done Erel
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice