1.3.3 • Published 1 year ago

@liftos-js/react-google-drive-picker v1.3.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

React-google-drive-picker

Google drive picker

Description

Google drive picker custom hook.

Getting Started

Installing

With npm

npm i @liftos-js/react-google-drive-picker

With yarn

yarn add @liftos-js/react-google-drive-picker

Usage

import  { useEffect } from 'react';
import useDrivePicker from '@liftos-js/react-google-drive-picker'


function App() {
  const [openPicker, authResponse] = useDrivePicker();  
  // const customViewsArray = [new google.picker.DocsView()]; // custom view
  const handleOpenPicker = () => {
    openPicker({
      // title: "Acme Group", -> optional
      clientId: "xxxxxxxxxxxxxxxxx",
      developerKey: "xxxxxxxxxxxx",
      viewId: "DOCS",
      // token: token, // pass oauth token in case you already have one
      showUploadView: true,
      showUploadFolders: true, 
      supportDrives: true, // shared drives feature enable and display on navbar
      multiselect: true,
      filterImagesAndVideos: true // images and videos menu activated on navbar
      filterPDFs: true // pdfs menu activated on navbar
      filterStarred: true // starred menu activated on navbar. display starred files and folders
      filterFolders: true // folders menu activated on navbar
      // 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)
filterImagesAndVideosbooleanfalseEnable image and video menu on navbar
filterPDFsbooleanfalseEnable pdfs menu on navbar
filterFoldersbooleanfalseEnable folders menu on navbar
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", "https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth/drive.metadata"Array of custom scopes you want to add to the picker
localestringenList of supported locales https://developers.google.com/picker/docs#i18n

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

@Selcuk Sarikoz

@Baris Ozdemirci

Author (v1.2.2)

@Jose medina

1.3.3

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.2

1 year ago