Update Any File on Google Drive with AI2
We know how to upload a file to google drive, but there may be times when you want to keep the same fileID but change the file with a new version. You can do this using Google Drive itself by right clicking on the file and selecting Manage Versions, which allows you to upload a new version of the file whilst retaining the fileID. This guide will show how you can do the same using a google apps script web app. I have used images in the example for visual return, but this could apply to any file type that you can convert to base64 and store on google drive. My thanks to Juan Antonio for the KIO4 Base64 Extension which helps to make this all work. This demo has blocks set to work in development/Companion mode, but should work for all Android versions. May need adjustment for a compiled app. Tested in companion mode (v2.60u) on Android 7 and Android 10.
The app allows the user to select a file from a list, this then displays the selected file. The user can then upload the file to google drive. If the file myImage.png does not exist then it is created using the uploaded file. If the file by that name does exist then the existing file is replaced with the uploaded file. The app then shows the responseContent with the fileID, and displays the file from Google Drive. This should be the same image as the one the user selected. The folder on google drive needs view permissions for everyone, in order to display the updated image in the app.
The blocks are setup to be used in development/Companion mode selecting png image files loaded in the assets.