Using the Google Drive API to Download Google Docs

By Travis McChesney in Developer Posted Nov 13, 2017

Cloud storage providers are becoming more popular and mainstream everyday.  And so are Cloud-only applications, like Google Drive. So what happens when you combine a popular Cloud storage application with a popular online document storage application like Google Drive? When you use the Google Drive API to download Google Docs, you get “documents” that are really just links to data in the cloud. In other words, Google Docs do not have their own file format or type, as Google Docs does not create “files” but rather creates symbolic links to the data that is your document in the cloud.

Google-Drive

Using the Google API to download Google Docs, like Cloud Elements does, results in an error, and results in no file being downloaded for the user or application. So how do you download a Google app document with their API?

When storing documents in Google Drive in any format other than Google Apps, the file downloads as expected from any other Cloud drive. They of course are files in readily recognized formats. The exception is documents created and stored in Google Apps on Google Drive. When a person tries to retrieve a Google App created document, they get an error. However Google provides aexport API to the most popular file formats to overcome the proprietary Google App format. Using that API, Google Docs can be converted to a Microsoft Word file, Google Spreadsheets will be converted to a Microsoft Excel file, and Google Presentations will be converted to a Microsoft PowerPoint. All other native Google documents will be converted to PDF files.  Google provides for other formats too, like Open Office files and PNG.

So the result is a file that opens in the program that you have configured to open .doc, .xls, .ppt and .pdf documents. It’s ironic that a Google Doc could also end up being a Microsoft Word document, all because Google Docs has no native file format.  We at Cloud Elements have made this translation part of our standard product.  Any developer using the Google Drive API’s should consider doing the same.

Google Drive API

Check out our other posts on integrating cloud file storage services or subscribe to our blog: