Skip to content

Instantly share code, notes, and snippets.

@hubgit
Created October 16, 2012 00:12
Show Gist options
  • Save hubgit/3896507 to your computer and use it in GitHub Desktop.
Save hubgit/3896507 to your computer and use it in GitHub Desktop.
Google Drive File Picker
// Note: the file must be shared with at least "anyone with the link can view" permissions.
var clientId = "YOUR CLIENT ID"; // from Google's API Console
google.load("picker", "1");
google.setOnLoadCallback(function() {
var picker = new google.picker.PickerBuilder()
.setAppId(clientId)
.addView(google.picker.ViewId.DOCUMENTS)
.enableFeature(google.picker.Feature.NAV_HIDDEN)
.setCallback(function(data) {
if (data[google.picker.Response.ACTION] == google.picker.Action.PICKED) {
var doc = data[google.picker.Response.DOCUMENTS][0];
var url = doc[google.picker.Document.URL];
$("#input").load(url.replace(/\/edit$/, "/export"));
}
})
.build();
picker.setVisible(true);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment