Showing documents from Google Drive on webpage

Ralph David Abernathy picture Ralph David Abernathy · Jan 26, 2014 · Viewed 8.3k times · Source

Is it possible to show the documents from my drive on a webpage? I want the user to be able to click the document and download it, directly from my drive. How would I go about doing this? Thank you for your suggestions.

Answer

diggie picture diggie · Apr 24, 2014

The fastest and easiest solution is to embed the folder using an iframe (no javascript needed). Obviously this is also the least flexible solution, although you can use CSS to change the layout of the iframe contents (see below).

Google Drive won't allow embedding of the url you would normally use. It has its X-Frame-Options header set to "SAMEORIGIN", preventing use in an iframe. So you have to use the following link, which will allow embedding:
https://drive.google.com/embeddedfolderview?id=DOCUMENT_ID#VIEW_TYPE

DOCUMENT_ID is the id that is mentioned in the normal share link (which looks like https://drive.google.com/folderview?id=DOCUMENT_ID), so you can just copy that from there.

VIEW_TYPE should be either 'grid' or 'list', depending on your preference.

And if you need to change the style of the iframe content, take a look at this solution.