Android Question How to upload large images?

Daica

Active Member
Licensed User
Hello everyone,
Currently I am using Camera2 library to take pictures and then converting the pictures to base64 and creating a json string that sends it to my PHP server.
The PHP server then collects the Json and convert the base64 back to an image and process it.

This works fine if I set the capture resolution to 1920x1080. The result of the image is about 1MB.
If I try to set a higher resolution for the capture, the program crashes due to "out of memory" error.

Did anyone here create a process or function that upload larger images to their server without using base64 since when you convert to base64, the data is larger?

I was thinking maybe split the base64 text into parts and upload it, but maybe someone else has a better idea?
 

DonManfred

Expert
Licensed User
Longtime User
okhttputils2 ->PostMultipart

No need to base64encode and no need to decode it on PHP-side...

I do upload images regularly using this. It like a fileupload coming from a form. Or even two or 10 files.
 
Upvote 0

Daica

Active Member
Licensed User
okhttputils2 ->PostMultipart

No need to base64encode and no need to decode it on PHP-side...

I do upload images regularly using this. It like a fileupload coming from a form. Or even two or 10 files.

When I post-string with my JSON string, it contains other information in there that I save to the database.
Is it possible with the PostMultipart to include more info that just the image?

I'm searching the forum now for examples
 
Upvote 0
Top