Android Question sending bitmap with http

catyinwong

Active Member
Licensed User
Longtime User
I am trying to send a post request with a bitmap in the body. With the following code I tried, the received request on the server side is empty. Anyone knows why?

B4X:
Dim bt as bitmap =loadbitmap(file.dirinternal, "testing.jpg")
Dim out as outputstreaam
out.initializeToBytesArray(0)
bt.writetoStream(output,100,"JPEG")

Dim j as httpjob: j.initialize("",me)
Dim url as string = 
j.postBytes(url, out.ToBytesArray)
 

drgottjr

Expert
Licensed User
Longtime User
not sure what this is all about:
Dim bt as bitmap =loadbitmap(file.dirinternal, "testing.jpg")
Dim out as outputstreaam
out.initializeToBytesArray(0)
bt.writetoStream(output,100,"JPEG")

this is the minimum you need:
B4X:
    Dim data() As Byte = File.ReadBytes(File.DirAssets, "testing.jpg")
    job.PostBytes( url, data)

plus i have no idea what your server is doing, but try the above. my server reports on the bytes received (attached) ...
adding a content type header wouldn't hurt.
 

Attachments

  • capture.PNG
    capture.PNG
    10 KB · Views: 82
Last edited:
Upvote 0

catyinwong

Active Member
Licensed User
Longtime User
not sure what this is all about:


this is the minimum you need:
B4X:
    Dim data() As Byte = File.ReadBytes(File.DirAssets, "testing.jpg")
    job.PostBytes( url, data)

plus i have no idea what your server is doing, but try the above. my server reports on the bytes received (attached) ...
adding a content type header wouldn't hurt.

In the server where can I find the bytes received? from request.headers?
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
Content-Length
 
Upvote 0
Top