Reading from file is garbled

I am reading a text file using Filey and File1 from Ai2 and both give the same issue.

I am reading a file from google drive to Ai2 using Metric Rat ai2 a published to his website.

Then I built my app around that. However when i read the Readme.txt file is get this as the result.
53225708 is in a file with the file name of Readme.txt
The response i get successfully read is NTMyMjU3MDg=

I have changed the text in the file several time and the successful read always changes with each new file contents. multiple reads of same file always returns the same string. so i don't think it is random.

Any idea?



Show the link to the Metricrat ai2

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

Here is the link to metric rat. I have modified to fit my needs better.

And my Companion app displays with a green background NTMyMjU3MDg=

Not completely obvious from your blocks as to what is happening, also given that you have modified the original guide somewhere, however, it seems that a file you have stored on your device is not being decoded back from a base64 string to a binary file, hence, you are getting a base64 string in your "text readed" output.

Or the file contents are encoded as base64, and therefore need to be decoded once read into the app.

All I can suggest is that you review your blocks workflow, using "Do It" to check the output of variables.

Worth noting that the tutorial/guide is quite outdated now, it would be quite different if I were to write it now :wink:

Below is the script that uploads the file to the app. Does this mean it is coded in Base 64?
Mp3 files work just fine. It is these text files that I can not find a way to bring the text of the file into my app as a variable.

// upload file to google drive sync folder

if ( e.parameter.func = "up" ) {

var data = Utilities.base64Decode(;

var blob = Utilities.newBlob(data, e.parameters.mimetype, e.parameters.filename);

var fileID = DriveApp.getFolderById('<FOLDER ID HERE>').createFile(blob).getId();

return listFiles();

Maybe the file app was not designed to move text files. What is required to convert back to binary?

Reply to outline a solution.

I ended up using KIO4_Base641 extension. this allowed my to convert the 64 bit into Text with the

I also ran into a problem with modifying the text file in google docs. It seems to save them as a PDF without an extension. I added a .txt and that really messed it up.
A text created/modified in notepad and then uploaded to Google Drive to keep is an authentic ,txt.

If working with text files on Google Drive (.txt or .csv), you might be interested in this:

I have read a lot about getting text files into the app. None just seem to work. My above solution worked in companion, but would not compile. App compiles just fine until I introduce anything from the extension KIO4_Base64 So I am back to being stuck.

I load simple text files and mp3 into my google drive. I synchronize these files into my ASD using MetricRat file server mentioned above. After this I need to about once each minute check the existence of a file based on a parameter. Example I want to check the existence of a file named Volume.txt If it exists, I want to read the text in file Volume.txt, "80" is what is saved in the file. Then this 80 will change the volume of the player in the app to 80. There will also be Serial output strings to peripheral devices to, called clacker, control light flashing and lights on or off. I can make all this work once i successfully read the text file. I am just missing this part.

Here I use 3 different File Exists functions. The one that returns false is the only one with a reader function.

Here i am troubleshooting the readme portion, so there are multiple readme attempts as well as other functions not germane to the problem.


This app will have internet to set it up, but once saved and put into automatic, there will be no internet connection available.

The app works perfectly with MP3 files, i just can not get the text to read into my software.

What's that? This does not make sense. .

Why not only using one?

Try file scope App together with a relative ASD path, i.e. /GDSync/Readme.txt


1 Like

The File component needs (uses) a relative path to the ASD with FileScope=App and a relative path to the root dir of the external storage with FileScope=Legacy.

So try as @Taifun suggested:

Thanks that worked, of all the combinations I have tried I cant believe I didn't try that. Wish me luck while I incorporate this enlightenment into the rest of the project.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.