Hi All,
I'm trying to add the file download handler to JRDC2:
with this code on linux server:
In the B4A side I have this code:
I don't receive any error, but the file in android side at the end of the procedure, it's empty (0 bytes).
Anyone could tell me where I'm doing wrong?
Thanks in advance!
I'm trying to add the file download handler to JRDC2:
with this code on linux server:
B4X:
'Handler class
Sub Class_Globals
End Sub
Public Sub Initialize
End Sub
Sub Handle(req As ServletRequest, resp As ServletResponse)
Dim out As OutputStream
Dim name As String = req.GetParameter("name")
Log(name)
Dim In As InputStream = File.OpenInput("/opt/jrdc2/files", name)
out.InitializeToBytesArray(0)
File.Copy2(In, out)
In.Close
Log("File " & File.Combine("/opt/jrdc2/files", name) & " Send!")
End Sub
In the B4A side I have this code:
B4X:
Sub ricevifile(filename As String)
Dim j As HttpJob
j.Initialize("", Me)
Dim out As OutputStream
j.Download2(ModVariabili.Server_Download,Array As String ("name",filename))
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Dim out As OutputStream = File.OpenOutput(File.Combine(File.DirInternal,"audio"), filename, False)
out.InitializeToBytesArray(0)
File.Copy2(j.GetInputStream, out)
out.Close
End If
j.Release
End Sub
I don't receive any error, but the file in android side at the end of the procedure, it's empty (0 bytes).
Anyone could tell me where I'm doing wrong?
Thanks in advance!