🟦 Update/Replace Existing File on Google Drive, Keeping the Same File ID

This demo guide shows you how to update an existing file on google drive through App Inventor. This method retains the original file ID, therefore this can be useful where you may have links to a specific file on Google Drive.

7 Likes

It works for me!

At first the update did not work for me, only the upload of the first file worked.
When updating I got the error:
"Drive" is not defined "

I went to Resources - Advanced Google services and checked
Drive API v2, now updates work for me.

A small change, maybe it is not necessary to upload the "mimetype" since we can obtain it directly in the Script:

Drive.Files.update ({title: filename, mimeType: file.getMimeType ()}, fileID, blob);

Thanks Juan, I kept meaning to add that to the guide, but kept forgetting!! Will add it now :wink: [edit - done]

Regarding your second point, I haven't tested it but, it is probably possible to upload a different mimetype to the same filename, e.g. a jpg file to a file named .myImage.png. You can leave off the file extension to avoid confusion, just calling it myImage, and upload any mimetype you like to the file, retaining the fileID.

The Web App Script URL - where exactly does one publish the script?

https://developers.google.com/apps-script/overview
https://developers.google.com/apps-script/guides/web

and