Google File Picker API with Google Drive (Google App Script)

Google File Picker API with Google Drive
The Google File Picker API lets users simply transfer files to Google Drive. And conjointly choose existing files and folders from Drive. The File transfer Forms for Google Drive are written in Google Apps Script. It lets users transfer files to the shape owner’s folder through the File Picker API.

As You Know, Google Drive is one of the most popular file storage. And synchronization service in the world that, developed by Google. Google is a safe and trusted point. And we most of the time engaged with Google in our daily life and using Google's product or services.

As the trusted point of Google. Drive is also popular cloud storage in the industry, for Google's trust and safety policies. We can't think about this online industry without Google. So, when it comes to start using Cloud store, We can start using Drive because of our data safety.

Here’s whole living proof. That shows a way to integrate the File Picker API with a Google Apps Script primarily based internet app. You’d have to be compelled to alter the Google Picker API from your Google Console. And additionally, generate the developer’s key. You can check out a demo here.
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: "files",
developerKey: "", // Update 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,
// picker.html
<!DOCTYPE html>
    <base target="_top">
    <link rel="stylesheet" href="">
    <script type="text/javascript" src=""></script>
    <script>google.load("picker", "1");</script>    
  <body style="margin:20px;">
    <div class="block form-group">
      <button onclick="openPicker()" type="button" class="btn btn-primary">Select Files</button>
      <button onclick="openUploader()" type="button" class="btn btn-primary">Upload Files</button>
      <div id="message"></div>
    <?!= include("javascript"); ?>
// javascript.html

function openPicker() {

function openUploader() {

function showFilePicker(config) {

// Show all files in Google Drive for selection
var view = new google.picker.DocsView(google.picker.ViewId.DOCS);


// Show file as a grid or list (compact)
if (config.picker.viewMode === "GRID")

if (config.picker.mimeTypes)

var picker = new google.picker.PickerBuilder()
.setSize(config.dialogDimensions.width - 2,
config.dialogDimensions.height - 2);

if (config.picker.hideTitle)

// Show files / folders owned by the user
if (config.picker.mineOnly)

if (config.picker.navhidden)

// Allow uses to select multiple files / folders
if (config.picker.multiselectEnabled)


function showFileUploader(config) {

var upload = new google.picker.DocsUploadView()


// allowFolderSelect and multiselectEnabled should be enabled
// setting parent folder disables folder selection
if (config.parentFolder)

// Limit the user from uploading specific types
if (config.picker.mimeTypes)

var picker = new google.picker.PickerBuilder()
.setSize(config.dialogDimensions.width - 2,
config.dialogDimensions.height - 2);

if (config.picker.hideTitle)

if (config.picker.navhidden)

if (config.picker.multiselectEnabled)


// Callback function
function fileSelected(data) {
var html = [];
var action = data[google.picker.Response.ACTION];
if (action == google.picker.Action.PICKED) {
var documents = data[google.picker.Response.DOCUMENTS];
for (var i = 0 ; i < documents.length ; i++) {
} else if (action == google.picker.Action.CANCEL) {
html.push("No file selected");

function showMessage(message){
document.getElementById("message").innerHTML = message;

You can easily build a File Picker API for Google Drive Remote File Upload. By using the codes in Google Apps Script, that I've provided in this article. I'm damn sure, you will be avail to start using Drive REMOTELY. And this will help you to upload your files to the cloud. As your personal or commercial use. As it is 100% free to use the codes on Apps Scripts to any purpose.

Last Worlds,

You can use this script to store or upload your personal files to Drive. Or start uploading your website's files like Audio, Video, and Images to Drive. Also, you use js files on your website from Drive as CDN.
Google File Picker API with Google Drive (Google App Script) Google File Picker API with Google Drive (Google App Script) Reviewed by Abdul Alim on January 06, 2020 Rating: 5

No comments:

Powered by Blogger.