You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@turbodocx/react-google-drive-picker

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turbodocx/react-google-drive-picker

React google drive picker api

1.2.3
latest
Source
npmnpm
Version published
Weekly downloads
10
900%
Maintainers
1
Weekly downloads
 
Created
Source

React-google-drive-picker (Hard Fork by TurboDocx)

Google Drive Picker custom hook, maintained by TurboDocx.

Description

Google Drive picker custom hook.

Getting Started

Installing

With npm

npm i react-google-drive-picker

With yarn

yarn add react-google-drive-picker

Usage

import  { useEffect } from 'react';
import useDrivePicker from 'react-google-drive-picker'


function App() {
  const [openPicker, authResponse] = useDrivePicker();  
  // const customViewsArray = [new google.picker.DocsView()]; // custom view
  const handleOpenPicker = () => {
    openPicker({
      clientId: "xxxxxxxxxxxxxxxxx",
      developerKey: "xxxxxxxxxxxx",
      viewId: "DOCS",
      // token: token, // pass oauth token in case you already have one
      showUploadView: true,
      showUploadFolders: true,
      supportDrives: true,
      setEnableDrives: false, // this adds support for Shared Drives on Premium Google Workspace plans. 
      multiselect: true,
      // customViews: customViewsArray, // custom view
      callbackFunction: (data) => {
        if (data.action === 'cancel') {
          console.log('User clicked cancel/close button')
        }
        console.log(data)
      },
    })
  }


  
  return (
    <div>
        <button onClick={() => handleOpenPicker()}>Open Picker</button>
    </div>
  );
}

export default App;

Picker configuration props

Picker Props

paramsvaluedefault valuedescription
callbackFunctionfunctionREQUIREDCallback function that will be called on picker action
clientIdstringREQUIREDGoogle client id
developerKeystringREQUIREDGoogle developer key
disableDefaultViewbooleanfalsedisables default view
viewIdstringDOCSViewIdOptions
viewMimeTypesstringoptionalComma separated mimetypes. Use this in place of viewId if you need to filter multiple type of files. list: https://developers.google.com/drive/api/v3/mime-types.
setIncludeFoldersbooleanfalseShow folders in the view items.
setSelectFolderEnabledbooleanfalseAllows the user to select a folder in Google Drive.
tokenstringoptionalaccess_token to skip auth part
setOriginstringoptionalSets the origin of the Google Picker dialog
multiselectbooleanfalseEnable picker multiselect
supportDrivesbooleanfalseSupport shared drives
showUploadViewbooleanfalseEnable upload view
showUploadFoldersbooleanfalseEnable folder selection(upload)
setParentFolderstringdisabledDrive folder id to upload
customViewsViewClass[]optionalArray of custom views you want to add to the picker
customScopesstring[]['https://www.googleapis.com/auth/drive.readonly']Array of custom scopes you want to add to the picker
localestringenList of supported locales https://developers.google.com/picker/docs#i18n
setEnableDrivesbooleanfalseEnables the selection of Shared Drives (Requires Premium Google Workspace plans)

viewId options

optiondescription
DOCSAll Google Drive document types.
DOCS_IMAGESGoogle Drive photos.
DOCS_IMAGES_AND_VIDEOSGoogle Drive photos and videos.
DOCS_VIDEOSGoogle Drive videos.
DOCUMENTSGoogle Drive Documents.
FOLDERSGoogle Drive Folders.
DRAWINGSGoogle Drive Drawings.
FORMSGoogle Drive Forms.
PDFSPDF files stored in Google Drive.
SPREADSHEETSGoogle Drive Spreadsheets.

Author

Originally Created by @Jose medina Maintained by the TurboDocx Team.

Acknowledgments

Inspiration, code snippets

  • sdoomz
  • obonyojimmy

Proudly Sponsored by TurboDocx "Proudly Sponsored by TurboDocx"

Keywords

react

FAQs

Package last updated on 26 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.