Android – problem with sending pictures using URLConnection

I’ve encountered a problem while sending pictures to an API. No matter what MIME type I set or which format I use (EncodeHex, EncodeBase64, sending as Binary), some bytes (characters) have disappeared. When comparing the data before sending the request with the data from the response, I noticed that the original data has 80389 characters, but the response only returns 80383 characters. These discrepancies appear in random places, approximately every 120th line of Base64 decoded data. Has anyone else encountered this problem, or could it be an Android error? It doesn’t seem to be an issue with the API because the problem doesn’t occur in an iOS app created in Xojo.

@Dominik_Sieciński Here’s a snippet of code that shows how I’m sending pictures via URLConnection.

In my Android app, the code runs in the “Selected” event handler of a MobileImagePicker control instance. I’m converting the picture to a memoryblock, converting that to a string, and then Base64 encoding the string. The string is sent in the body of a URLConnection request.

Var MB As MemoryBlock = pic.ToData( Picture.Formats.PNG ) 
Var Content As String = MB.StringValue( 0, MB.Size )
Var ContentEncoded As String = EncodeBase64( Content, 0 )


Var Username As String = "SomeUsername"
Var Password As String = "SomePassword"
Var URL As String = "https://analyzer.mnmlsw.com"


Var Authorization As String = EncodeBase64( Username + ":" + Password )


URLConnection1.RequestHeader( "Authorization") = "Basic " + Authorization
URLConnection1.SetRequestContent( ContentEncoded, "text")


URLConnection1.Send( "POST", URL, 30 )

I hope you find this to be useful.

1 Like

Unfortunately, @Tim_Dietrich your solution didn’t help. The problem still occurs.
I’ve tried to make a simple Android app to sending photos and simple Web app, to receiving them and saving as a file.

Android project:

const URL as String = "https://photo.xojocloud.net/photo"

Var MB As MemoryBlock = ikon.ToData(Picture.Formats.PNG) 
Var Content As String = MB.StringValue(0, MB.Size)
Var ContentEncoded As String = EncodeBase64( Content, 0 )
URLConnection1.SetRequestContent( ContentEncoded, "application/octet-stream")
URLConnection1.Send("POST", URL)

Web project:

if request.Path = "photo" then
  try
    var encodedBody as String = request.Body
    var mb as MemoryBlock = DecodeBase64(encodedBody)
    response.Write("Decoded: ["+encodedBody.Length.ToString+"] "+ EndOfLine)
    
    // Saving file with data
    var savedData as new FolderItem(SpecialFolder.Documents.Child("data.png"))
    var os as TextOutputStream = TextOutputStream.Create(savedData)
    os.Write(mb)
    os.Close
    response.Write("Saved as file.")
    
    
    var p as Picture = Picture.FromData(mb)
    response.Write("Picture.FromData" + EndOfLine)
    var file as new FolderItem(SpecialFolder.Documents.Child("picture.png"))
    response.Write("Created file." + EndOfLine)
    p.Save(file, Picture.Formats.JPEG)
    response.Write("Saved as picture.")
  catch ex as RuntimeException
    response.Write(ex.Message)
  end try
 return true
end if

Sending quite small image (369 × 385 px, 4 871 bytes) works, but for bigger ones it doesn’t.
To check if there might be any dependency, I’ve tried to send a few the same small photos (there was also a problem with sending them using JSONItem). As you can see on the screenshot below, I’ve sent 10 photos, and only 4 of them were saved properly. Rest of them have some issues.

It is difficult to understand which ones were saved properly.

Files data0.png, data2.png, data5.png, data8.png were saved properly (that’s why all pictureX.png could be created).

1 Like

@Dominik_Sieciński I’m running into this now, too.

I think the issue has to do with Android’s support for EncodeBase64. I think it is either truncating the string being passed to it, or truncating the result. If I EncodeBase64 a large-ish string (such as a photo selected via an ImageViewer control), and then use DecodeBase64 on the result, I get nothing back. Sometimes it hangs the emulator, but not always. But it never seems to be able to decode properly.

@Jeremie_L This seems similar to the URLConnection encoding issue that we were both running into about a month ago. (https://tracker.xojo.com/xojoinc/xojo/-/issues/74360#note_563766)

I’m going to look into this some more later, and if I can confirm what I think I’m seeing, I’ll file an issue for it.

Thanks for mentioning me Tim, this certainly explains a problem that appeared this afternoon in my error reporting tool.
The online API is responding with 204-No content.
Although I am 100% sure some base64 encoded data was sent.

If you get a chance, in your app, would you see what happens if you decode the Base64-encoded data that you’re sending to the API?

This is it:

(Supposed to be well formed json)

{"circle":{"userID":"746426","user_uuid":"B8A9BCA0-9AD3-49DC-AA4A-2BE0A7651A33","name":"Posada intercambio","budget":"500","event_date":"2023-12-02","circle_version":"2","circle_uuid":"AB2E6205-6CC4-4E32-88EC-98F97781B93B"},"circle_members":[{"circle_uuid":"AB2E6205-6CC4-4E32-88EC-98F97781B93B","name":"xxxxxxx","email":"579bebfd323a5e64a037c5de87cb14fd1fad9358","isadmin":true,"member_uuid":"41D75E50-EEAD-44FB-97AE-A149163F4584"},
{"circle_uuid":"AB2E6205-6CC4-4E32-88EC-98F97781B93B","name":"lacho","email":"2a956602d45fe8b86d09cdb8a9b7303bb860bd76","isadmin":false,"member_uuid":"39C21023-FBC8-4434-8094-3C7A320253F9"},
{"circle_uuid":"AB2E6205-6CC4-4E32-88EC-98F97781B93B","name":"yamy","email":"85f9ab2acc39903ec74fef7b3ec41f0a98c6a98a","isadmin":false,"member_uuid":"1324A2C9-F358-4D30-AF0A-1F5865A59ED6"},
{"circle_uuid":"AB2E6205-6CC4-4E32-88EC-98F97781B93B","name":"gera","email":"de76c6016b3053c7c0d89ebe9e3edf3c192572e8","isadmin":false,"member_uuid":"16499707-59E9-46AE-852F-CD254770A324"},
{"circle_uuid":"AB2E6205-6CC4-4E32-88EC-98F97781B93B","name":"nora","email":"dab196a89ff991b445911eda5a0175196c1b3982","isadmin":false,"member_uuid":"8FFCCC3B-703F-4B47-B0ED-8CE65F0AA075"},
{"circle_uuid":"AB2E6205-6CC4-4E32-88EC-98F97781B93B","name":"memo","email":"ee8fe65efe8d9c0da9e3e38e174a4fafa1d593c8","isadmin":false,"member_uuid":"ACA3189E-C1CE-4CBF-989B-103EA1E2F78B"},
{"circle_uuid":"AB2E6205-6CC4-4E32-88EC-98F97781B93B","name":"denisse","email":"dd73274d88bd70cf949f3e7d22cc2254bb06461f","isadmin":false,"member_uuid":"B916AB03-987F-4653-A720-D31F4457FDFD"},
{"circle_uuid":"AB2E6205-6CC4-4E32-88EC-98F97781B93B","name":"Robert","email":"6152e8fb7cd28be12a3ffab7ee49a2b6e816b882","isadmin":false,"member_uuid":"6811E4D2-53AB-44C8-9CD4-F0C167D69013"},
{"circle_uuid":"AB2E6205-6CC4-4E32-88EC-98F97781B93B","name":"cristo","email":"b62ed2fe3f511f253d1e9db6bd3643d9bbfca9c6","isadmin":false,"member_uuid":"11BA2798-719E-4BAF-B7D8-802F54D0A4AB"},
{"circle_uuid":"AB2E6205-6CC4-4E32-88EC-98F97781B93B","name":"gis","email":"287f5fc41c04d17fddfc15dc69eb4a24e7381861","isadmin":false,"member_uuid":"FEC9AA9D-3395-4356-9339-E5C6B5AC5118"},
{"circle_uuid":"AB2E6205-6CC4-4E32-88EC-98F97781B93B","name":"Humberto","email":"00e4d5448f17a00ff890b1d340da6efd5f5d3f77","isadmin":false,"member_uuid":"32DF2EBE-C22E-4A83-B33F-CCD232C598D0"}],"circle_couples":[{"circle_uuid":"AB2E6205-6CC4-4E32-88EC-98F97781B93B","member1_uuid":"41D75E50-EEAD-44FB-97AE-A149163F4584","member2_uuid":"39C21023-FBC8-4434-8094-3C7A320253F9","couple_uuid":"8C517C83-C8AD-46CE-BD4C-6502002C7F52"},
{"circle_uuid":"AB2E6205-6CC4-4E32-88EC-98F97781B93B","member1_uuid":"1324A2C9-F358-4D30-AF0A-1F5865A59ED6","member2_uuid":"16499707-59E9-46AE-852F-CD254770A324","couple_uuid":"655F0AC6-9A48-4144-84A3-D51B4653CDA9"},
{"circle_uuid":"AB2E6205-6CC4-4E32-88EC-98F97781B93B","member1_uuid":"8FFCCC3B-703F-4B47-B0ED-8CE65F0AA075","member2_uuid":"ACA3189E-C1CE-4CBF-989B-103EA1E2F78B","couple_uuid":"D355C512-CE31-465B-A962-C42CF61E6195"},
{"circle_uuid":"AB2E6205-6CC4-4E32-88EC-98F97781B93B","member1_uuid":"B916AB03-987F-4653-A720-D31F4457FDFD","member2_uuid":"6811E4D2-53AB-44C8-9CD4-F0C167D69013","couple_uuid":"2206FDFB-6A36-42AF-8856-7122504A043A"},
{"circle_uuid":"AB2E6205-6CC4-4E32-88EC-98F97781B93B","member1_uuid":"FEC9AA9D-3395-4356-9339-E5C6B5AC5118","member2_uuid":"32DF2EBE-C22E-4A83-B33F-CCD232C598D0","couple_uuid":"4E069609-7DE5-4304-960D-3C2AD4C288FB"}],"circle_pairs":[{"circle_uuid":"AB2E6205-6CC4-4E32-88EC-98F97781B93B","from_member_uuid":"8FFCCC3B-703F-4B47-B0ED-8CE65F0AA075","to_member_uuid":"6811E4D2-53AB-44C8-9CD4-F0C167D69013","pair_uuid":"23037530-5EE3-4465-A7B1-9563E8C260D7","message_data":"{\"firstname\":\"nora\",\"app_name\":\"Secret Santa\",\"year\":\"2023\",\"admin_name\":\"xxxxxxx\",\"admin_email\":\"xxxxxxxxxx@gmail.com\",\"admin_image\":\"https:\\\/\\\/www.gravatar.com\\\/avatar\\\/000000000000000071a600f567666047?d=mp&s=120\",\"event_name\":\"Posada intercambio\",\"event_date\":\"2 de diciembre de 2023\",\"gift_name\":\"Robert\",\"budget\":\"500\",\"hasAff\":\"true\",\"affURL\":\"https:\\\/\\\/amzn.to\\\/2Q1VMe4\",\"goURL\":\"https:\\\/\\\/scrtsanta.app\\\/go\\\/?url=https%3A%2F%2Famzn.to%2F2Q1VMe4\",\"wishlistURL\":\"https:\\\/\\\/wishlist.scrtsanta.app\\\/?pid=23037530-5EE3-4465-A7B1-9563E8C260D7\",\"pair_uuid\":\"23037530-5EE3-4465-A7B1-9563E8C260D7\",\"templateID\":\"d-f84732939bc54231a70b66bfbc89e13b\"}"},
{"circle_uuid":"AB2E6205-6CC4-4E32-88EC-98F97781B93B","from_member_uuid":"FEC9AA9D-3395-4356-9339-E5C6B5AC5118","to_member_uuid":"41D75E50-EEAD-44FB-97AE-A149163F4584","pair_uuid":"1C841F30-42C1-4A9A-8F32-684B4EB1EC62","message_data":"{\"firstname\":\"gis\",\"app_name\":\"Secret Santa\",\"year\":\"2023\",\"admin_name\":\"xxxxxxx\",\"admin_email\":\"xxxxxxxxxx@gmail.com\",\"admin_image\":\"https:\\\/\\\/www.gravatar.com\\\/avatar\\\/000000000000000071a600f567666047?d=mp&s=120\",\"event_name\":\"Posada intercambio\",\"event_date\":\"2 de diciembre de 2023\",\"gift_name\":\"xxxxxxx\",\"budget\":\"500\",\"hasAff\":\"true\",\"affURL\":\"https:\\\/\\\/amzn.to\\\/2Q1VMe4\",\"goURL\":\"https:\\\/\\\/scrtsanta.app\\\/go\\\/?url=https%3A%2F%2Famzn.to%2F2Q1VMe4\",\"wishlistURL\":\"https:\\\/\\\/wishlist.scrtsanta.app\\\/?pid=1C841F30-42C1-4A9A-8F32-684B4EB1EC62\",\"pair_uuid\":\"1C841F30-42C1-4A9A-8F32-684B4EB1EC62\",\"templateID\":\"d-f84732939bc54231a70b66bfbc89e13b\"}"},
{"circle_uuid":"AB2E6205-6CC4-4E32-88EC-98F97781B93B","from_member_uuid":"1324A2C9-F358-4D30-AF0A-1F5865A59ED6","to_member_uuid":"8FFCCC3B-703F-4B47-B0ED-8CE65F0AA075","pair_uuid":"F104D47B-F8FC-4D5A-888F-DA07A75B7604","message_data":"{\"firstname\":\"yamy\",\"app_name\":\"Secret Santa\",\"year\":\"2023\",\"admin_name\":\"xxxxxxx\",\"admin_email\":\"xxxxxxxxxx@gmail.com\",\"admin_image\":\"https:\\\/\\\/www.gravatar.com\\\/avatar\\\/000000000000000071a600f567666047?d=mp&s=120\",\"event_name\":\"Posada intercambio\",\"event_date\":\"2 de diciembre de 2023\",\"gift_name\":\"nora\",\"budget\":\"500\",\"hasAff\":\"true\",\"affURL\":\"https:\\\/\\\/amzn.to\\\/2Q1VMe4\",\"goURL\":\"https:\\\/\\\/scrtsanta.app\\\/go\\\/?url=https%3A%2F%2Famzn.to%2F2Q1VMe4\",\"wishlistURL\":\"https:\\\/\\\/wishlist.scrtsanta.app\\\/?pid=F104D47B-F8FC-4D5A-888F-DA07A75B7604\",\"pair_uuid\":\"F104D47B-F8FC-4D5A-888F-DA07A75B7604\",\"templateID\":\"d-f84732939bc54231a70b66bfbc89e13b\"}"},
{"circle_uuid":"AB2E6205-6CC4-4E32-88EC-98F97781B93B","from_member_uuid":"11BA2798-719E-4BAF-B7D8-802F54D0A4AB","to_member_uuid":"B916AB03-987F-4653-A720-D31F4457FDFD","pair_uuid":"3EB758F8-5C52-4F5D-A362-8B94FECCED52","message_data":"{\"firstname\":\"cristo\",\"app_name\":\"Secret Santa\",\"year\":\"2023\",\"admin_name\":\"xxxxxxx\",\"admin_email\":\"xxxxxxxxxx@gmail.com\",\"admin_image\":\"https:\\\/\\\/www.gravatar.com\\\/avatar\\\/000000000000000071a600f567666047?d=mp&s=120\",\"event_name\":\"Posada intercambio\",\"event_date\":\"2 de diciembre de 2023\",\"gift_name\":\"denisse\",\"budget\":\"500\",\"hasAff\":\"true\",\"affURL\":\"https:\\\/\\\/amzn.to\\\/2Q1VMe4\",\"goURL\":\"https:\\\/\\\/scrtsanta.app\\\/go\\\/?url=https%3A%2F%2Famzn.to%2F2Q1VMe4\",\"wishlistURL\":\"https:\\\/\\\/wishlist.scrtsanta.app\\\/?pid=3EB758F8-5C52-4F5D-A362-8B94FECCED52\",\"pair_uuid\":\"3EB758F8-5C52-4F5D-A362-8B94FECCED52\",\"templateID\":\"d-f84732939bc54231a70b66bfbc89e13b\"}"},
{"circle_uuid":"AB2E6205-6CC4-4E32-88EC-98F97781B93B","from_member_uuid":"32DF2EBE-C22E-4A83-B33F-CCD232C598D0","to_member_uuid":"16499707-5NKM
êQKN
LëãP—çM
ÕÃLÃçãúZ\ó›]ZYéàê–Q
Ãç–KMêÕåÀM–ÕÀNPÃÀMM
ÕççPëMêQ»ãõY\‹ÿYŸWŸ]Héàû◊ôö\ú›eò[YWéóí[Xô\ùe◊ãò\€ò[YWéóîŸX‹ô]ÿ[ùWãûYX\óéóååå◊ãòYeZ[ó€ò[YWéóêúö\‹⁄XWãòYeZ[óŸ[XZ[éóòúö\‹⁄X[Zú–€XZ[ò€€WãòYeZ[ó⁄[XYŸWéóöŒó◊›››Àô‹ò]ò]\ãò€€Wÿ]ò]\óÃMXôåÕŸôçYXLçÃXMåçMçÕççå

œŸ[\	úœLLåãô]ô[ù€ò[YWéóîe‹ÿYH[ù\òÿ[Xö[◊ãô]ô[ùŸ]WéóåàHX⁄Y[XúôHHåå◊ãô⁄Yù€ò[YWéóôŸ\òWãòùYŸ]éóçLãö\–YôóéóùùYWãòYôïTìéóöŒó◊ÿ[^õãùe◊ÃîLUìYMãô€’TìéóöŒó◊‹ÿ‹ùÿ[ùKò\Ÿ€◊œ›\õZ…L–ILëâLëò[^õãùe…LëåîLUìYMãù⁄\⁄e\›TìéóöŒó◊›⁄\⁄e\›úÿ‹ùÿ[ùKò\œ‹YP–Q
Ãç–KMêÕåÀM–ÕÀNPÃÀMM
ÕççPëMêQ◊ãúZ\ó›]ZYéóê–Q
Ãç–KMêÕåÀM–ÕÀNPÃÀMM
ÕççPëMêQ◊ãù[\e]RQéóôYé

ÃÃéLŒXòÕMåÃXMÃççòôòòŒYLLÿóüHüK»ò⁄\ò€W›]ZYéàêPåëMåå
KMê–ÕMLÃãNPÀNNéMÕŒPéL–àãôúõ€W€Y[Xô\ó›]ZYéàåŒPÃåLåÀQêêŒM
ÕNML–Õ–LÃåçL—éHãùe◊€Y[Xô\ó›]ZYéàêP–LÃNQKPÃP—KM–ëãNNPãLL—PLQLëçŒàãúZ\ó›]ZYéàëLPÕéMÃê—MMPãN–ãMPÕÖL

êÕëãõY\‹ÿYŸWŸ]Héàû◊ôö\ú›eò[YWéóõX⁄e◊ãò\€ò[YWéóîŸX‹ô]ÿ[ùWãûYX\óéóååå◊ãòYeZ[ó€ò[YWéóêúö\‹⁄XWãòYeZ[óŸ[XZ[éóòúö\‹⁄X[Zú–€XZ[ò€€WãòYeZ[ó⁄[XYŸWéóöŒó◊›››Àô‹ò]ò]\ãò€€Wÿ]ò]\óÃMXôåÕŸôçYXLçÃXMåçMçÕççå

œŸ[\	úœLLåãô]ô[ù€ò[YWéóîe‹ÿYH[ù\òÿ[Xö[◊ãô]ô[ùŸ]WéóåàHX⁄Y[XúôHHåå◊ãô⁄Yù€ò[YWéóõY[[◊ãòùYŸ]éóçLãö\–YôóéóùùYWãòYôïTìéóöŒó◊ÿ[^õãùe◊ÃîLUìYMãô€’TìéóöŒó◊‹ÿ‹ùÿ[ùKò\Ÿ€◊œ›\õZ…L–ILëâLëò[^õãùe…LëåîLUìYMãù⁄\⁄e\›TìéóöŒó◊›⁄\⁄e\›úÿ‹ùÿ[ùKò\œ‹YQLPÕéMÃê—MMPãN–ãMPÕÖL

êÕëãúZ\ó›]ZYéóëLPÕéMÃê—MMPãN–ãMPÕÖL

êÕëãù[\e]RQéóôYé

ÃÃéLŒXòÕMåÃXMÃççòôòòŒYLLÿóüHüK»ò⁄\ò€W›]ZYéàêPåëMåå
KMê–ÕMLÃãNPÀNNéMÕŒPéL–àãôúõ€W€Y[Xô\ó›]ZYéàêéLMêPåÀNN
—ãM
çLÀPMÃåQÃQç

M—ëëãùe◊€Y[Xô\ó›]ZYéàëëPŒPPNQLÃŒMKMÕMãNLÃŒKQMPÕêçPPÕLLNãúZ\ó›]ZYéàëéêÕÃMPKNN
éMÃKPP—QLPL–MÃÃMãõY\‹ÿYŸWŸ]Héàû◊ôö\ú›eò[YWéóô[ö\‹ŸWãò\€ò[YWéóîŸX‹ô]ÿ[ùWãûYX\óéóååå◊ãòYeZ[ó€ò[YWéóêúö\‹⁄XWãòYeZ[óŸ[XZ[éóòúö\‹⁄X[Zú–€XZ[ò€€WãòYeZ[ó⁄[XYŸWéóöŒó◊›››Àô‹ò]ò]\ãò€€Wÿ]ò]\óÃMXôåÕŸôçYXLçÃXMåçMçÕççå

œŸ[\	úœLLåãô]ô[ù€ò[YWéóîe‹ÿYH[ù\òÿ[Xö[◊ãô]ô[ùŸ]WéóåàHX⁄Y[XúôHHåå◊ãô⁄Yù€ò[YWéóô⁄\◊ãòùYŸ]éóçLãö\–YôóéóùùYWãòYôïTìéóöŒó◊ÿ[^õãùe◊ÃîLUìYMãô€’TìéóöŒó◊‹ÿ‹ùÿ[ùKò\Ÿ€◊œ›\õZ…L–ILëâLëò[^õãùe…LëåîLUìYMãù⁄\⁄e\›TìéóöŒó◊›⁄\⁄e\›úÿ‹ùÿ[ùKò\œ‹YQéêÕÃMPKNN
éMÃKPP—QLPL–MÃÃMãúZ\ó›]ZYéóëéêÕÃMPKNN
éMÃKPP—QLPL–MÃÃMãù[\e]RQéóôYé

ÃÃéLŒXòÕMåÃXMÃççòôòòŒYLLÿóüHüK»ò⁄\ò€W›]ZYéàêPåëMåå
KMê–ÕMLÃãNPÀNNéMÕŒPéL–àãôúõ€W€Y[Xô\ó›]ZYéàçQ
ÕQMLQQPQM
êãNM–QKPLMLMå—ç
N
ãùe◊€Y[Xô\ó›]ZYéàåLÃçLêŒKQåÕNMÃPQåKLQçN
çPMNQQ
àãúZ\ó›]ZYéàê—çPÕP–éMêêMÀMPLêçÀLêçÃ
Ã
ÕçÕNHãõY\‹ÿYŸWŸ]Héàû◊ôö\ú›eò[YWéóêúö\‹⁄XWãò\€ò[YWéóîŸX‹ô]ÿ[ùWãûYX\óéóååå◊ãòYeZ[ó€ò[YWéóêúö\‹⁄XWãòYeZ[óŸ[XZ[éóòúö\‹⁄X[Zú–€XZ[ò€€WãòYeZ[ó⁄[XYŸWéóöŒó◊›››Àô‹ò]ò]\ãò€€Wÿ]ò]\óÃMXôåÕŸôçYXLçÃXMåçMçÕççå

œŸ[\	úœLLåãô]ô[ù€ò[YWéóîe‹ÿYH[ù\òÿ[Xö[◊ãô]ô[ùŸ]WéóåàHX⁄Y[XúôHHåå◊ãô⁄Yù€ò[YWéóûX[^WãòùYŸ]éóçLãö\–YôóéóùùYWãòYôïTìéóöŒó◊ÿ[^õãùe◊ÃîLUìYMãô€’TìéóöŒó◊‹ÿ‹ùÿ[ùKò\Ÿ€◊œ›\õZ…L–ILëâLëò[^õãùe…LëåîLUìYMãù⁄\⁄e\›TìéóöŒó◊›⁄\⁄e\›úÿ‹ùÿ[ùKò\œ‹YP—çPÕP–éMêêMÀMPLêçÀLêçÃ
Ã
ÕçÕNWãúZ\ó›]ZYéóê—çPÕP–éMêêMÀMPLêçÀLêçÃ
Ã
ÕçÕNWãù[\e]RQéóôYé

ÃÃéLŒXòÕMåÃXMÃççòôòòŒYLLÿóüHüK»ò⁄\ò€W›]ZYéàêPåëMåå
KMê–ÕMLÃãNPÀNNéMÕŒPéL–àãôúõ€W€Y[Xô\ó›]ZYéàçéLQMãML–PãM
ŒNP—
QåÃMç—
éLL»ãùe◊€Y[Xô\ó›]ZYéàåÃëåëPëKPÃåëKMNÀPå×ãP–—åÃêÕNNãúZ\ó›]ZYéàê–åêNLPçãLå—
ãMåÃKPMMÕQMŒÃQMåQPP»ãõY\‹ÿYŸWŸ]Héàû◊ôö\ú›eò[YWéóîõÿô\ùãò\€ò[YWéóîŸX‹ô]ÿ[ùWãûYX\óéóååå◊ãòYeZ[ó€ò[YWéóêúö\‹⁄XWãòYeZ[óŸ[XZ[éóòúö\‹⁄X[Zú–€XZ[ò€€WãòYeZ[ó⁄[XYŸWéóöŒó◊›››Àô‹ò]ò]\ãò€€Wÿ]ò]\óÃMXôåÕŸôçYXLçÃXMåçMçÕççå

œŸ[\	úœLLåãô]ô[ù€ò[YWéóîe‹ÿYH[ù\òÿ[Xö[◊ãô]ô[ùŸ]WéóåàHX⁄Y[XúôHHåå◊ãô⁄Yù€ò[YWéóí[Xô\ùe◊ãòùYŸ]éóçLãö\–YôóéóùùYWãòYôïTìéóöŒó◊ÿ[^õãùe◊ÃîLUìYMãô€’TìéóöŒó◊‹ÿ‹ùÿ[ùKò\Ÿ€◊œ›\õZ…L–ILëâLëò[^õãùe…LëåîLUìYMãù⁄\⁄e\›TìéóöŒó◊›⁄\⁄e\›úÿ‹ùÿ[ùKò\œ‹YP–åêNLPçãLå—
ãMåÃKPMMÕQMŒÃQMåQPP◊ãúZ\ó›]ZYéóê–åêNLPçãLå—
ãMåÃKPMMÕQMŒÃQMåQPP◊ãù[\e]RQéóôYé

ÃÃéLŒXòÕMåÃXMÃççòôòòŒYLLÿóüHüK»ò⁄\ò€W›]ZYéàêPåëMåå
KMê–ÕMLÃãNPÀNNéMÕŒPéL–àãôúõ€W€Y[Xô\ó›]ZYéàåMçNMÃ
ÀMNQNKM
êQKN
LëãP—çM
ÕÃLÃçãùe◊€Y[Xô\ó›]ZYéàåŒPÃåLåÀQêêŒM
ÕNML–Õ–LÃåçL—éHãúZ\ó›]ZYéàåŒQçMéKMMåQKM
PQãNMéMLMMçLN–LHãõY\‹ÿYŸWŸ]Héàû◊ôö\ú›eò[YWéóôŸ\òWãò\€ò[YWéóîŸX‹ô]ÿ[ùWãûYX\óéóååå◊ãòYeZ[ó€ò[YWéóêúö\‹⁄XWãòYeZ[óŸ[XZ[éóòúö\‹⁄X[Zú–€XZ[ò€€WãòYeZ[ó⁄[XYŸWéóöŒó◊›››Àô‹ò]ò]\ãò€€Wÿ]ò]\óÃMXôåÕŸôçYXLçÃXMåçMçÕççå

œŸ[\	úœLLåãô]ô[ù€ò[YWéóîe‹ÿYH[ù\òÿ[Xö[◊ãô]ô[ùŸ]WéóåàHX⁄Y[XúôHHåå◊ãô⁄Yù€ò[YWéóõX⁄e◊ãòùYŸ]éóçLãö\–YôóéóùùYWãòYôïTìéóöŒó◊ÿ[^õãùe◊ÃîLUìYMãô€’TìéóöŒó◊‹ÿ‹ùÿ[ùKò\Ÿ€◊œ›\õZ…L–ILëâLëò[^õãùe…LëåîLUìYMãù⁄\⁄e\›TìéóöŒó◊›⁄\⁄e\›úÿ‹ùÿ[ùKò\œ‹YLŒQçMéKMMåQKM
PQãNMéMLMMçLN–LWãúZ\ó›]ZYéóåŒQçMéKMMåQKM
PQãNMéMLMMçLN–LWãù[\e]RQéóôYé

ÃÃéLŒXòÕMåÃXMÃççòôòòŒYLLÿóüHüK»ò⁄\ò€W›]ZYéàêPåëMåå
KMê–ÕMLÃãNPÀNNéMÕŒPéL–àãôúõ€W€Y[Xô\ó›]ZYéàêP–LÃNQKPÃP—KM–ëãNNPãLL—PLQLëçŒàãùe◊€Y[Xô\ó›]ZYéàåLPêLçŒNMÃNQKMêQãPç—NëçMMPàãúZ\ó›]ZYéàêÃåPåçãQN
MãNLçåPå—ÃMÕMëãõY\‹ÿYŸWŸ]Héàû◊ôö\ú›eò[YWéóõY[[◊ãò\€ò[YWéóîŸX‹ô]ÿ[ùWãûYX\óéóååå◊ãòYeZ[ó€ò[YWéóêúö\‹⁄XWãòYeZ[óŸ[XZ[éóòúö\‹⁄X[Zú–€XZ[ò€€WãòYeZ[ó⁄[XYŸWéóöŒó◊›››Àô‹ò]ò]\ãò€€Wÿ]ò]\óÃMXôåÕŸôçYXLçÃXMåçMçÕççå

œŸ[\	úœLLåãô]ô[ù€ò[YWéóîe‹ÿYH[ù\òÿ[Xö[◊ãô]ô[ùŸ]WéóåàHX⁄Y[XúôHHåå◊ãô⁄Yù€ò[YWéóò‹ö\›e◊ãòùYŸ]éóçLãö\–YôóéóùùYWãòYôïTìéóöŒó◊ÿ[^õãùe◊ÃîLUìYMãô€’TìéóöŒó◊‹ÿ‹ùÿ[ùKò\Ÿ€◊œ›\õZ…L–ILëâLëò[^õãùe…LëåîLUìYMãù⁄\⁄e\›TìéóöŒó◊›⁄\⁄e\›úÿ‹ùÿ[ùKò\œ‹YPÃåPåçãQN
MãNLçåPå—ÃMÕMëãúZ\ó›]ZYéóêÃåPåçãQN
MãNLçåPå—ÃMÕMëãù[\e]RQéóôYé

ÃÃéLŒXòÕMåÃXMÃççòôòòŒYLLÿóüHüW_

EDIT, the base64encode starts screwing up data at the 7500th position.

Sure looks like a bug to me.

Want me to file it?

1 Like

Yes please file it. I don’t have time to make an example project right now.

I have clearly identified the problem. Sending data through URLConnection

  • sent and received size are identical
  • misses a byte every 10.000 bytes
  • repeats the last byte for every every missed byte

Sending data smaller than 10kB shouldn’t be affected.
Sending 15kB data will miss one byte and repeat the last byte once.
Sending 35kB data will miss three bytes and repeat the last byte 3 times.

https://tracker.xojo.com/xojoinc/xojo/-/issues/74792

1 Like

@Jeremie_L Jeremie Great work tracking down the cause of this. I suppose as a work around, we could send the payload in <10kB chunks. I might give that a try.

I haven’t filed the Base64-encoding issue yet. I think that’s a separate issue. Agreed?

Just did a test, there is no Base64 issue. The problem was sending a large (>10kB) Base64 string through URLConnection.

I guess I missed that sentence in Dominik’s post.
As Base64 is 4/3 bigger than original string, 4871 byte image is fine (~6495 bytes in base64).
Now we understand that larger images fail because they are above the 10kB threshold.

Exactly the issue I noticed: 7500*4/3=10000 (10kB) :slight_smile:

1 Like