Google Shows Off Some Drive API Secrets

Developer & DesignLeave a Comment

Share this Post

There were a lot of conferences and workshops during Google I/O this year. One of the newcomers to I/O - Google Drive APi - actually got some of the best workshops this year. That doesn't mean that everything was covered during the weeklong event of all things Google. The team has decided to show off some of the lesser known things you can do with the Google Drive API.

As you are probably aware, Google Drive is the company's answer to DropBox and all the other digital file lockers out there. While most just want to store their own content for personal use, you might also use the service to share files with others. Using the API, you can download a file without authentication if it has been shared publicly. All you have to do is send a GET request for the file metadata and look for the "webContentLink" to find the file.

When setting permissions via the Drive API, Google notes that you can choose "owner," "writer," "reader" and "commenter" for the role paramater. Strangely enough, you actually can't select commenter for the role paramater. To fix this, you have to grant the user the role of reader and then list "commenter" under "additionalRoles."

While you can restrict the list of files that are returned by the Drive API, you might want to sometimes return the entire folder via the root. To do this, you just have to submit a simple search query with "root" attached to the end.

Another simple tip is to check out the "About Feed" of the Drive API. In here, you can find all sorts of information including the quota that's left in a User's account. The quota is listed in bytes so have fun counting all the bytes that are in the free 5GB of data that's offered to every user.

One of the better functions of Drive, and what sets it apart from the competition, is that it can be used to open files with Chrome apps. Not all Chrome apps can take advantage of Drive though and it might not be readily apparent on the app's store page. To find out if an app can open a file via Drive, just retrieve the "Apps feed" and look for one of the following elements: "primaryMimeTypes, secondaryMimeTypes, primaryFileExtensions, and secondaryFileExtensions."

To learn more, check out Google's developer resources for the Drive API. You'll be building Drive apps with the best of them in no time.

Leave a Reply