I can use GAS script to upload a file to my drive as below:
media = MediaFileUpload(
filename,
mimetype=mimetype,
resumable=True
)
request = service.files().create(
media_body=media,
body={'name': remotefilename, 'parents': [folderId]}
)
But if I upload the same file multiple times, it will generate multiple copies. Is it possible to keep the same file but keep different version? just like what the UI update version does?
Solution:
Instead of a
createrequest, you can issue anupdaterequest to an existing file withnewRevisionparameter set totrueto create a new revision for the same file.For more information on how to use
Files: update, you can check the official API documentation.