Image To Base64 Not Working At All

After picking an image, you can check for encoding like this in companion:

image

You should also check that all of this is correct:

image

and matches with the parameters required by the google apps script (which you still have not shared)

If you are trying to set the base64 string to the content of a cell in google sheets, you only have 50,000 characters to play with. A 500kb image file is likely to have more characters than that.

I removed the extension that you posted because only the developer can upload an aix. Next time please post a link to developer’s topic or site like I did

nah ,i am not trying to put the string to content of a cell rather than i am inserting it using spreadsheet.insertImage() function all my variables are correct so far i have tested for all variable but only var file is unable to access.

Lemme just check for check for encoding in companion as u suggested and tell u result.

i tried that but i am not getting anything like the question mark in your image on companion screen.
block

can u share the extension if u have it , there might be a possibility that i may be using some upgraded version of library which is causing issue.

It is quite an old extension, I do not believe it has been changed or upgraded:

1 Like

i used this extension only and but still not getting the “?” in companion or the base64 string

if u think it is not upgraded and might be not working then what other solution u know to convert the image base64 in kodular platform.

Did you right click on the block and select Do it ?

Tested on Kodular, works just fine:

image

yeah but not getting any result.
i am using 500kB jpg images,i dont think they are too much big

Unfortunately, I am not a mind reader. If you do not share what you are doing, blocks, script, setup, I have no way of knowing where your issue lies.

To use Do it, your app must be connected to your companion, and you can then right click on the EncodeImage block and select Do It - AFTER you have selected an image with the imagepicker.

i just created a second project and used it to just get block results , u check if i am doing something wrong.
test.aia (30.1 KB)
u just try this your side none of this works for my selected file

Not setting image to image component but happily converting to base64

image

Aha, just tried with a bigger file, doesn’t work

This is why I work with App Inventor :wink:

Try using the KIO4 Base64 extension, and get the base64 from the loaded image:

2 Likes

I have no problems with your test aia (Companion & APK, tested on Android 11):

Image file size ?

1 Like

yeah i used it but it is only working for the assets in case i install apk, i have to do FileToStringASD with “//test.jpg” and else location doesnt work, also like your picture uses function .ImageToBase64 doesnt work for me, btw. my phone is OPPO A31