Google Picker for Google Drive

2k views Asked by At

Google Picker is cool in that it provides users a more modern experience:

  1. Familiar — The look-and-feel users will recognize from Google Drive and other Google properties.
  2. Graphical — A dialog experience, with many views showing previews or thumbnails.
  3. Streamlined — An inline, modal window, so users never leave the main application.

https://developers.google.com/picker/docs/?csw=1

However, it seems to aims for html service, and even need you to register your project before using it.

Is it possible to just use it as a personal GDoc Picker for my Google Drive? A simple working demo is very much appreciated.

EDIT: Thank you Trevor for your wonderful script. It works nice and charm for picking Google Docs under Google Drive.

To make the story full, could you also give an example to use the Google Picker as the folder Picker as well please?

Basically, I need to turn on:

  • DocsView.setIncludeFolders(true)
  • DocsView.setSelectFolderEnabled(true)
  • setInitialView(google.picker.​ViewId.FOLDERS)
1

There are 1 answers

2
Trevor Iampen On

This might be what you are looking for:

function doGet() {
  var app = UiApp.createApplication();  
  var selectCkH = app.createServerHandler('selectFile');  
  var closeHandler = app.createServerHandler('closeDocsPicker');
  var docsDialog = app.createDocsListDialog().showDocsPicker() 
      .addCloseHandler(closeHandler)
      .addSelectionHandler(selectCkH);
  docsDialog.setDialogTitle('Select a Doc From Drive:');
  return app;
}  

function closeDocsPicker() {
  var app = UiApp.getActiveApplication(); 
  // close operations
  return app;
}

function selectFile (e) {
  var app = UiApp.getActiveApplication(); 
  var fileId = e.parameter.items[0]['id'];
  app.add(app.createLabel('File Id of Selected Doc: '+fileId));
  return app;
}