Base 64 extension.
With this extension we can:
Convert an image, sound, video, pdf file,... to a Base 64 string.
Convert a Base 64 string to file.
Convert the Picture of an Image component to Base 64.
Set a Base 64 string as Picture in an Image component.
Convert a Picture from a Canvas to a Base 64 string.
Take a Picture with the Camera and convert it to Base 64 string
Download a file from the internet and convert it to Base 64.
Convert a Uri to Path.
- Why convert a file to Base 64?
To save it to a TinyDB.
To upload a text string to the internet, instead of a file (for example by PHP).
To work directly with the image without previously converting it to a file (for example TakePicture with Cam and load it in Canvas directly.)
Draw on a Canvas and pass it directly to an Image component.
- Where can we download the updated extension?
http://kio4.com/appinventor/277_extension_imagen_string.htm
- What blocks does the extension have?
I, @Juan_Antonio , as the author of this extension, allow any user to use it in their application for the MIT App Inventor Summer Appathon 2023.
14 Likes
1.- Image file in assets to Base 64. Base 64 to File in ASD. Show in Image2.
Base64_Simple.aia (487.9 KB)
2.- Interesting examples in this topic:
luc74
November 10, 2021, 4:31pm
7
Hi Juan,
which is the correct path to read the files for the "File to String" component?
in other word I should get a file in this folder, but it can't find it: file:///storage/emulated/0/Pictures/
If I check the string of the component "When KIO4_Base64 Got String" says "File not found "...
I have Android 11, maybe it gives some problems?
can you help me?
thanks
luc74
November 11, 2021, 10:16am
9
Thanks Juan,
but the problem is only in the path read by component "FileToString".
here my blocks:
The file exist as proved by the component FileExists and also the MimeType is correctly taken.
But only String doesn't work: the label Check_string says: "File not found"...
Check the code of my previous application.
Use "FileToStringASD"
luc74
November 11, 2021, 11:25am
11
what should I see in label 3 after button 4 is pushed?
in my phone using the AI Companion the label simply disappears... or is blank...
if I compile the app and use it, the 3rd label say false and correctly the last label says File not found....
Possibly it will be a problem with Android 11.
Try blocks
FileToStringDirect
set absolute path (/storage/emulated/0/Android/data/'namepackage'/files/aaa.png)
StringToFileASDDirect
set absolute path
1 Like
luc74
November 12, 2021, 10:45am
13
Thanks Juan_Antonio!!! now it works!
great job!
on android 11 How to convert xlsx file to string. xlsx file in in download folder and created by another application.
I have not tested directly with a file in Download on Android 11.
Try this, copy the file from Download to ASD (File component), pass it to base64 in the ASD directory.
2 Likes
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.