Android Question how to call php with string and byte

Masoud44

Member
Hi ...
I have a database in mysql with 2 fields (id as int, image as blob)
I used PostString to insert them, it is worked when using string type for data but the image in the string is big. so i decided to convert the image to bytes instead of string, because byte size is much smaller than string but i don't know how to Call php with string and bytes for insert into database
 

Masoud44

Member
Switch to jRDC2.
Hi Erel
Thank you for your suggestion.
But considering that the program is being released and I don't want to take risks and I don't have much time.
Maybe it's better i'm to try another way and do Switch to jRDC2 at a suitable time.
Maybe right now it's better with the combination putbyte and poststring I'll test it. of course, I know the upload speed will be slow.
 
Upvote 0

Masoud44

Member
No, I didn't use Json
I'm currently using the same base64 but the file size increases with base64.
length of file:
    Dim out As OutputStream
    out.InitializeToBytesArray(0)
    Image.WriteToStream(out, 100, "JPEG")
    out.Close
    Log("length -------------------------------------") 
    Log(out.ToBytesArray.Length)   ------> 821,114
    Dim su As StringUtils
    Log(su.EncodeBase64(out.ToBytesArray).Length)  ------> 1,756,124
    Return out.ToBytesArray
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
Unfortunately, if you are using Multipart post to upload the file then the data will be encoded using BASE64.

I have uploaded very large image files using this method to a php server. It is sometimes slow, but is works. You do need to remember to update your php.ini withe the upload file size limits.
INI:
; Maximum allowed size for uploaded files.
upload_max_filesize = 10M

; Must be greater than or equal to upload_max_filesize
post_max_size = 12M

; Maximum amount of memory a script may consume (32MB)
memory_limit = 128M

; Maximum number of files that can be uploaded via a single request
max_file_uploads = 20
 
Upvote 0

Masoud44

Member
Ah, I see. Why is that a problem?
this is said about INSERT INTO table1 VALUES(v1,v2,...) with two way of use:
1-LOAD_FILE('path and file name')
LOAD_FILE() is a string function(not byte) and this is use for save file name and path of it.
2- Insert file as hex string, e.g. -
INSERT INTO table1 VALUES (1, x'89504E470D0A1A0A0000000D494........426082');
and this good for save hex string (not byte)
 
Upvote 0
Top