Tuesday, March 26, 2013

Host public files and sites in Google Drive


Problem:
Using the Google Drive SDK Client API, how to get a public URL of a file in order to present it on an existing website, directly (not "downloading" it)?


Solution:
Use the getId() method to retrieve the fieldId property.

View mode:
$image_embed_url = "https://drive.google.com/uc?export=view&id=" . $current_file->getId();#view url




Download mode:
$image_embed_url = "https://drive.google.com/uc?export=download&id=" . $current_file->getId();#download url



Source:
http://stackoverflow.com/questions/10311092/displaying-files-e-g-images-stored-in-google-drive-on-a-website/11855448#11855448

Alternate quick method for public single file sharing:
http://www.gdriveurl.com/

Using webViewLink() (didn't work for me, returned empty)
http://googleappsdeveloper.blogspot.ca/2012/11/announcing-google-drive-site-publishing.html

No comments:

Post a Comment