Google Apps Script Drive SDK API Access

Can I use the Google Drive API in Google Apps Script. I know about the DocsList Service, which allows you to view folders and files, but what about all the other Google Drive APIs (files, changes, children, parents, permissions, changes, applications, comments, answers). For example, is there access to the API to add comments to files from Google Apps Script.

+4
source share
4 answers

(Google-Apps-Script = GAS) Disk services added on 05/05/13 (to be announced later ) in 2013 by Google I / O in two days), which seems to be ideal for replacing the previous API (DocsList) and allows GAS to receive access to the Google Drive SDK, although this functionality is not mentioned (why?) from these white papers at the moment, but it is certainly proposed by the new new name of the Drive API and indicated as a target Great Google Drive Integration demo video with Google Apps Script, “Google I / O 2013” and “Drive SDK” are referred to as searchFiles (String) by search functions.

And the disk management services work (I use it, and although I could think of many improvements, I did not find any errors in the memory), including for useful applications (see the video above for one of the most impressive ones that I saw), but it is not complete (including the full SDK of the drive), including:

  • he has not yet allowed access to previous versions of the content (like this plus plus (improvement request: Google search "Problem 2811: accessing documents using DriveApp"),
  • manage indexing status and content mode,
  • It is not possible to get a list of files or folders (apparently, the video intentionally says, but using the previous DocsList or Library mentioned would seem to be a workaround).

I would include more links to help, but I have a new poster here, so the editor tells me: "You need at least 10 reputations to place more than two links."

+2
source

Script applications have the ability to access the Google APIs, but you need to explicitly enable them before using them.

In the code editor, select RESOURCES , ADDITIONAL GOOGLE SERVICES

Advanced google services

Press the “OFF” button to enable the service.

Before closing the dialog box, click the link below to open the API manager.

API Manager

Once you complete these two steps, the drive's API is accessible inside the Script applications. Enter the keyword Drive , then enter the period, and the available methods will appear in the list.

Methods

  • get - Gets the file metadata by identifier.
  • insert - insert a new file. Patch
  • - updates file metadata. This method supports the semantics of the patch.
  • update - updates file metadata and / or contents.
  • copy - creates a copy of the specified file.
  • delete - Permanently deletes a file by ID. Skips the trash.
  • list - List of user files.
  • touch - set the file update time to the current server time.
  • trash - moves a file to the trash
  • untrash - restores a file from the recycle bin.
  • watch - start viewing the changes in the file.
  • emptyTrash - Permanently deletes all files with damaged users.

https://developers.google.com/drive/v2/reference/files#methods

+2
source

Yes it is possible.

Take a look at the documentation for the Class File , which includes functions for getting and / or changing most of the attributes you listed.

For an example of code that receives some information about these files and folders, see this answer .

0
source

You should also take a look at this library written by Romain Vialard, one of the TC GS.

It provides features that are not available directly in the gas, or at least not so simple.

0
source

All Articles