Google File Picker API with Google Drive – Working Example

The Google File Picker API lets users easily upload files to Google Drive and also select existing files and folders from Drive.┬áThe File Upload Forms for Google Drive is written in Google Apps Script and it lets users upload files to the form owner’s folder through the File Picker API.

Here’s a complete working example that shows how to integrate the File Picker API with a Google Apps Script based web app. You’d need to enable the Google Picker API from your Google Console and also generate the developer’s key.

function doGet() {    
  return HtmlService
  .addMetaTag("viewport", "width=device-width, initial-scale=1")
  .setTitle("Google Drive Picker")

function include(fileName) {
  return HtmlService

function initPicker() {
  return {
    locale: 'en',
    token: ScriptApp.getOAuthToken(),
    origin: "",
    parentFolder: "xyz",
    developerKey: "",
    dialogDimensions: {
      width: 600, 
      height: 425
    picker: {
      viewMode: "LIST",
      mineOnly: true,
      mimeTypes: "image/png,image/jpeg,image/jpg",
      multiselectEnabled: true,
      allowFolderSelect: true,
      navhidden: true,
      hideTitle: true,
      includeFolders: true,

// For Scope
// DriveApp.getStorageUsed()
// DriveApp.getFilesByName("")
// picker.html
// Offers button for uploading and selecting files


// javascript.html