The advanced Drive service lets you use the Google Drive API in Apps Script. Much like Apps Script's built-in Drive service, this API allows scripts to create, find, and modify files and folders in Google Drive. In most cases, the built-in service is easier to use, but this advanced service provides a few extra features, including access to custom file properties as well as revisions for files and folders.
Reference
For detailed information on this service, see the reference documentation for the Google Drive API. Like all advanced services in Apps Script, the advanced Drive service uses the same objects, methods, and parameters as the public API. For more information, see How method signatures are determined.
To report issues and find other support, see the Drive API support guide.
Sample code
The code samples in this section use version 3 of the API.
Upload files
The following code sample shows how to save a file to a user's Drive.
List folders
The following code sample shows how to list the top-level folders in the user's Drive. Note the use of page tokens to access the full list of results.
List revisions
The following code sample shows how to list the revisions for a given file. Note that some files can have several revisions and you should use page tokens to access the full list of results.
Add file properties
The following code sample uses the appProperties
field to add a custom
property to a file. The custom property is only visible to the script. To add a
custom property to the file that's also visible to other apps, use the
properties
field, instead. For more information, see Add custom file
properties.