Android Question size field after POST

Uniko Sistemi srl

Active Member
Licensed User
Hi everyone!
I have a problem that I don't understand how it is generated.
I make a call with job.poststring to insert fields into my sql including a base64 string (longtext).
I noticed that only for the base64 string when I generate it to send it it has a size of 78600 bytes, when it is sent I go to check the size on the server and it is 78614 bytes and therefore the decoding to read it from my device no longer works! Has anyone had the same problem or knows why it adds these 14bytes to me (it only adds them in the base64 string field). Furthermore, if I manually upload the base64 string to the server the size remains, while with the post it does not....
Thanks to anyone who can give me advice!
 

DonManfred

Expert
Licensed User
Longtime User
Upload a small project showing the problem.

What do you get back when reading it from the database? Add some log (maybe to a file) to get inspired what the dirrerence is.

Maybe add a log of the content AS HEX to a file. The bytes you are sending.
Add sa log for the bytes you get back from the database. As HEX. write it to a file.

Compare them.
 
Last edited:
Upvote 0

Uniko Sistemi srl

Active Member
Licensed User
Hiding ALL THE INFO on how you generate the base64 string, how it is saved into the database.

How can we help with nearly ZERO information you provide?

Upload a small project showing the problem.
example:
 Dim  B64String As String

    B64String = Base64EncodeDecodeImage.Base64ImageToString(File.DirAssets,"LISTINO CONCESSIONARI 23-24.pdf")

    Log(B64String.Length)

  

    'Check if Valid Base64

    If Base64EncodeDecodeImage.ValidBase64(B64String) Then

        Base64EncodeDecodeImage.Base64StringToAnyFile(B64String, File.Dirinternal, "convert.pdf")

        Log("buono")

    end if

    Dim job As HttpJob

    job.Initialize("gestfile", Me) 

    job.PostString("http://" & globe.Serverip & "/prova.php","action=gestfile&nomefile=nomepdf&file64="&B64String&")
 
Upvote 0

Uniko Sistemi srl

Active Member
Licensed User
example:
 Dim  B64String As String

    B64String = Base64EncodeDecodeImage.Base64ImageToString(File.DirAssets,"LISTINO CONCESSIONARI 23-24.pdf")

    Log(B64String.Length)

 

    'Check if Valid Base64

    If Base64EncodeDecodeImage.ValidBase64(B64String) Then

        Base64EncodeDecodeImage.Base64StringToAnyFile(B64String, File.Dirinternal, "convert.pdf")

        Log("buono")

    end if

    Dim job As HttpJob

    job.Initialize("gestfile", Me)

    job.PostString("http://" & globe.Serverip & "/prova.php","action=gestfile&nomefile=nomepdf&file64="&B64String&")

Yes, that's right, here's some info. With this procedure I get a size of 78600 and everything is sent correctly to the server. But if I go to the server to check the size it is 14bytes more. It happens for any pdf file I convert
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upload a small PROJECT showing the Problem. Hard to help with the codesnippet you posted.

It is of exactly ZERO help to post just a small code but NO project, no files to test with (PDF). not seing the difference, ect.

Add some log on SENDER side to know 100% what you are sending.
Add some log in the RECEIVING side to know 100% what you are getting.

Maybe write them both to a textfile and compare them...
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
But if I go to the server to check the size it is 14bytes more
Are you sure you are posting the string correctly? Looks like you are adding a spurious quote at the end of the string
B4X:
job.PostString("http://" & globe.Serverip & "/prova.php","action=gestfile&nomefile=nomepdf&file64="&B64String&")
Try this and see if it makes a difference
B4X:
job.PostString($"http://${globe.Serverip}/prova.php"$,$"action=gestfile&nomefile=nomepdf&file64=${B64String}"$)
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
you are surely right. But i guess it can not be 14 bytes...
True, but the spurious quote could muck with the post content processing on the server side and therefore create a larger string (I'm totally guessing here). We'll have to wait for the OP to test and report back.
 
Upvote 0
Top