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.
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.
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
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(e.parameters.data);
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?
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.
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.
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.
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.