B4J Programming Press on the image to return to the main documentation page.

JSch

List of types:

SFtp
SFtpEntry

SFtp

This library wraps JSch open source project. It supports the SFTP protocol.
See this tutorial for more information.

Events:

DownloadCompleted (ServerPath As String, Success As Boolean)
DownloadProgress (ServerPath As String, TotalDownloaded As Long, Total As Long)
UploadCompleted (ServerPath As String, Success As Boolean)
UploadProgress (ServerPath As String, TotalUploaded As Long, Total As Long)
CommandCompleted (Command As String, Success As Boolean, Reply As String)
PromptYesNo (Message As String)
ShowMessage (Message As String)
ListCompleted (ServerPath As String, Success As Boolean, Folders() As SFtpEntry, Files() As SFtpEntry)

Members:


  Activity_Resume

  Chmod (Path As String, Permissions As String)

  Close

  CloseNow

  DeleteFile (ServerFilePath As String)

  DownloadFile (ServerFilePath As String, DeviceFolder As String, DeviceFile As String)

  GetCurrentPath

  Initialize (EventName As String, Username As String, Password As String, Host As String, Port As Int)

  List (ServerPath As String)

  Mkdir (Path As String)

  Rename (OldPath As String, NewPath As String)

  SetKnownHostsStore (Dir As String, FileName As String)

  SetPromptResult (Result As Boolean)

  UploadFile (DeviceFolder As String, DeviceFile As String, ServerFilePath As String)

Members description:

Activity_Resume
This method should be called in Activity_Resume. It will call the PromptYesNo event again (if the message was visible before).
Chmod (Path As String, Permissions As String)
Sets the permissions of the given file. The permissions should be formatted as a three digits octal number.
The CommandCompleted event will fire when operation completes.
Example:
sftp1.Chmod("/home/user/somefile", "644")
Close
Closes the connection after all submitted tasks finish. Note that this method does not block.
CloseNow
Closes the connection immediately without waiting for current tasks to finish.
DeleteFile (ServerFilePath As String)
Deletes the given file. The CommandCompleted event will be raised with the command "delete".
DownloadFile (ServerFilePath As String, DeviceFolder As String, DeviceFile As String)
Downloads a file from the server. The DownloadCompleted event will be raised when download completes.
DownloadProgress events will be raised during download.
ServerFilePath - Full path to the remote file.
DeviceFolder - Folder that the file will be saved to.
DeviceFile - The name of the local file that will be created.
GetCurrentPath
Gets the current server path. The CommandCompleted event will be raised with the command "pwd".
Initialize (EventName As String, Username As String, Password As String, Host As String, Port As Int)
Initializes the SFtp object.
EventName - The event subs prefix.
Username - The user name.
Password - User password.
Host - SSH host.
Port - SSH port (default is 22).
List (ServerPath As String)
Fetches the list of folders and files in the specified path.
The ListCompleted event will be raised when the data is available.
Mkdir (Path As String)
Creates a new folder.
Rename (OldPath As String, NewPath As String)
Renames the given file. The CommandCompleted event will fire when operation completes.
SetKnownHostsStore (Dir As String, FileName As String)
Sets the file that stores the known hosts.
SetPromptResult (Result As Boolean)
Sets the result of the server prompt. The network thread waits for this call for up to 60 seconds.
After 60 seconds the result will be set to False (No) automatically.
UploadFile (DeviceFolder As String, DeviceFile As String, ServerFilePath As String)
Uploads a file to the server. The UploadCompleted event will be raised when upload completes.
UploadProgress events will be raised during the upload.
DeviceFolder - Local folder.
DeviceFile - Local file name.
ServerFilePath - Full path to file that will be created on the server.

SFtpEntry

SFtpEntry represents a file or a folder. Call SFtp.List to get the files and folders.

Events:

None

Members:


  IsInitialized As Boolean

  Name As String [read only]

  Size As Long [read only]

  Timestamp As Long [read only]

Members description:

IsInitialized As Boolean
Name As String [read only]
Size As Long [read only]
Timestamp As Long [read only]

Top