Dim in As InputStream
Dim data() As Byte = stream.ToBytesArray
in.InitializeFromBytesArray(data, 0, data.Length)
cin.Initialize(in) 'global CountingInputStream
req.InitializePost(Link, cin, data.Length)
Thanks but i use library no classIt is only relevant if the file is quite large.
You need to modify HttpJob.PostMultipart.
1. Add a global CountingInputStream variable to HttpJob.
2. Remove the call to PostBytes and instead send the request with this code:
B4X:Dim in As InputStream Dim data() As Byte = stream.ToBytesArray in.InitializeFromBytesArray(data, 0, data.Length) cin.Initialize(in) 'global CountingInputStream req.InitializePost(Link, cin, data.Length)
You can now track the progress with a timer by checking Job.cin.Count.
It is only relevant if the file is quite large.
You need to modify HttpJob.PostMultipart.
1. Add a global CountingInputStream variable to HttpJob.
2. Remove the call to PostBytes and instead send the request with this code:
B4X:Dim in As InputStream Dim data() As Byte = stream.ToBytesArray in.InitializeFromBytesArray(data, 0, data.Length) cin.Initialize(in) 'global CountingInputStream req.InitializePost(Link, cin, data.Length)
You can now track the progress with a timer by checking Job.cin.Count.
Sub Class_Globals
Public JobName As String
Public Success As Boolean
Public Username, Password As String
Public ErrorMessage As String
Private target As Object
Public CountInputStream As Int
...
Public Cin As InputStream
Thanks for fast answering!Add reference to RandomAccessFile library.
You should read what he wroteHi @Erel . What is "cin" ... where is its declaration ?
It is only relevant if the file is quite large.
You need to modify HttpJob.PostMultipart.
1. Add a global CountingInputStream variable to HttpJob.
2. Remove the call to PostBytes and instead send the request with this code:
You can now track the progress with a timer by checking Job.cin.Count.B4X:Dim in As InputStream Dim data() As Byte = stream.ToBytesArray in.InitializeFromBytesArray(data, 0, data.Length) cin.Initialize(in) 'global CountingInputStream req.InitializePost(Link, cin, data.Length)
Public Cin As InputStream
dim cis as CountingInputStream ' THIS is what Erel wrote/suggested above
Hi @DonManfred ... Thanks! You are my help from an eternal stupid loop... I knew that was simple !!! I tried to find the CountInputStream object BEFORE adding RandomAccessFileLibrary... and didn't tried again after!!! I really didn't notice that this object was dependent of this library.B4X:dim cis as CountingInputStream ' THIS is what Erel wrote/suggested above
Ok... not yetB4X:dim cis as CountingInputStream ' THIS is what Erel wrote/suggested above
b = s.Replace(CRLF, eol).GetBytes("UTF8")
stream.WriteBytes(b, 0, b.Length)
'PostBytes(Link, stream.ToBytesArray)
Dim in As InputStream
Dim data() As Byte = stream.ToBytesArray
in.InitializeFromBytesArray(data, 0, data.Length)
Cin.Initialize(in) 'global CountingInputStream
req.InitializePost(Link, Cin, data.Length)
req.SetContentType("multipart/form-data; boundary=" & boundary)
req.SetContentEncoding("UTF8")
Hi @DonManfred ... I added a network spy at server side... the request using req.InitializePost(Link, Cin, data.Length) (HttpRequest) doesn't arrive at server... and there is no any message in Android also..Hi @DonManfred ... Thanks! You are my help from an eternal stupid loop... I knew that was simple !!! I tried to find the CountInputStream object BEFORE adding RandomAccessFileLibrary... and didn't tried again after!!! I really didn't notice that this object was dependent of this library.
Sometimes when we are programming we need an external help to see what we can't, maybe due the proximity (or caffeine excess, who knows!) - thanks again! You saved my day!
'PostBytes(Link, stream.ToBytesArray)
Dim in As InputStream
Dim data() As Byte = stream.ToBytesArray
in.InitializeFromBytesArray(data, 0, data.Length)
Cin.Initialize(in) 'global CountingInputStream
req.InitializePost(Link, Cin, data.Length)
Log("length -> " & data.Length)
req.SetContentType("multipart/form-data; boundary=" & boundary)
req.SetContentEncoding("UTF8")
CallSubDelayed2(HttpUtils2Service, "SubmitJob", Me)