Hi, i'm trying to use the Jsch lib for B4A in B4J due that i read that Erel said it should work in B4J but is not tested yet (https://www.b4x.com/android/forum/t...sed-on-jsch-tutorial.26994/page-2#post-228078), I try to make a test project for upload a file to a sftp server and everithing seems to work, the program sucessfully connects to the server and upload the file, but when you try to open the file it is partially uploaded for example a picture, it upload half picture or sometimes creates the file but with no info (0kb), this is the log i get:
and this is the code:
the same code works on b4a.
maybe i forget to initialize something?, or it's better use other lib for sftp??
thanks in advance!!
christian.
B4X:
Waiting for debugger to connect...
Program started.
0: Success
at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2629)
at com.jcraft.jsch.ChannelSftp._put(ChannelSftp.java:545)
at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:491)
at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:461)
at anywheresoftware.b4a.objects.SFtpWrapper$1.run(SFtpWrapper.java:116)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
/home/iccca/USL2.jpg, Success=false
0: Success
0: Success
at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2629)
at com.jcraft.jsch.ChannelSftp._put(ChannelSftp.java:545)
at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:491)
at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:461)
at anywheresoftware.b4a.objects.SFtpWrapper$1.run(SFtpWrapper.java:116)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
/home/iccca/USL2.jpg, Success=false
0: Success
and this is the code:
B4X:
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Dim sftp1 As SFtp
Private Button1 As Button
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.SetFormStyle("DEFAULT")
MainForm.RootPane.LoadLayout("main") 'Load the layout file.
sftp1.Initialize("sftp1", "usr", "pswrd", "srvr", 22)
sftp1.SetKnownHostsStore(File.DirApp, "hosts.txt")
MainForm.Show
End Sub
Sub sftp1_PromptYesNo (Message As String)
Dim res As Int = fx.Msgbox2(MainForm,Message, "", "Yes", "", "No",Null)
'The next line might be a bit confusing. It is a condition.
'The value will be True if res equals to DialogResponse.POSITIVE.
sftp1.SetPromptResult(res = fx.DialogResponse.POSITIVE)
'sftp1.SetPromptResult(True)
End Sub
Sub sftp1_ShowMessage (Message As String)
fx.Msgbox(MainForm,Message, "")
End Sub
Sub sftp1_UploadProgress (ServerPath As String, TotalUploaded As Long, Total As Long)
Dim s As String
s = "Uploaded " & Round(TotalUploaded / 1000) & "KB"
If Total > 0 Then s = s & " out of " & Round(Total / 1000) & "KB"
Log(s)
End Sub
Sub sftp1_UploadCompleted (ServerPath As String, Success As Boolean)
Log(ServerPath & ", Success=" & Success)
If Success = False Then Log(LastException.Message)
End Sub
Sub Button1_Action
sftp1.UploadFile(File.DirAssets,"USL2.jpg","/home/iccca/USL2.jpg")
End Sub
the same code works on b4a.
maybe i forget to initialize something?, or it's better use other lib for sftp??
thanks in advance!!
christian.