Hi,
B4A V7.8
I'm facing an issue to send a file from B4A to a web service and I don't know if this problem occur on B4A side or on WS side.
Here is my B4A code:
Dim Out2 As OutputStream
Out2.InitializeToBytesArray(0)
Dim In As InputStream = File.OpenInput(File.DirRootExternal, "photo.jpg")
File.Copy2(In, Out2)
Dim Input As Map
Input.Initialize
Input.Put("Fic",Out2.ToBytesArray)
Dim JSONGenerator As JSONGenerator
JSONGenerator.Initialize(Input)
Dim Job1 As HttpJob
Job1.Initialize("Photo", "Phototest")
Job1.PostString(Main.URL & "tools/file", JSONGenerator.ToPrettyString(2))
Job1.GetRequest.SetHeader("Authorization",Main.MyToken)
Job1.GetRequest.SetContentType("application/json")
Job1.GetRequest.Timeout = 600000
On my VB.net web service side, code is also very simple:
<[POST]("file")>
<HttpPost()>
Public Function Send(<FromBody()> Web As List(Of SByte)) As Boolean
'code to store the file in data base
'.....
Return True
End Function
If my jpg is a small one (200kb) this code is successfull.
If I try the same with a picture with size = 3.5Mb it fails.
In this second case, it never comes into my WS code.
I've also tried with Job1.PostFile without result ....
Well, my question is:
How to well code an upload file in both codes with such file ?
Thanks in advance for your feedback.