反应- 谷歌驱动拾取器
谷歌驱动器拾取器
说明
Google驱动器自定义钩.
开始
安装
与 npm 关系
npm i @fyelci/react-google-drive-picker
用纱线
yarn add @fyelci/react-google-drive-picker
使用量
import { useEffect } from 'react';
import useDrivePicker from '@fyelci/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,
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;
拾取器配置道具
拾取器道具
| 段落 | 价值 | 默认值 | 说明 |
|---|---|---|---|
| 回调功能 | 函数 | 需求 | 在拾取器动作上调用回调函数 |
| 客户端ID | 字符串 | 需求 | 谷歌客户端 ID |
| 开发者Key | 字符串 | 需求 | Google 开发者密钥 |
| 禁用默认查看 | 布尔 | 虚假 | 禁用默认视图 |
| 视图 | 字符串 | 医生 | 视图 |
| 视图MIME 类型 | 字符串 | 选项 | 逗号分离出 MIME 类型 。 如果您需要过滤多类文件, 请使用此选项取而代之 。 列表 : https://developers.google.com/drive/api/v3/mime-types (英语)。 。 。 . |
| 设置 | 布尔 | 虚假 | 在视图项目中显示文件夹 . |
| 设置 : | 布尔 | 虚假 | 允许用户在 Google Drive 中选择文件夹 . |
| 符号 | 字符串 | 选项 | 连接以跳过认证部分 |
| 设置 | 字符串 | 选项 | 设置 Google Picker 对话框的来源 |
| 多选择 | 布尔 | 虚假 | 启用多选取器 |
| 支持驱动程序 | 布尔 | 虚假 | 支持共享驱动器 |
| 显示载入视图 | 布尔 | 虚假 | 启用上传视图 |
| 显示装入文件夹 | 布尔 | 虚假 | 启用文件夹选择( 上载) |
| 设定父文件夹 | 字符串 | 已禁用 | 驱动文件夹 ID 上传 |
| 自定义视图 | 视图分类 [] | 选项 | 要添加到拾取器中的自定义视图阵列 |
| 自定义缩写 | 字符串 [] | [https://www.googleapis.com/auth/drive.read only'] (英语) | 要添加到拾取器中的自定义瞄准镜阵 |
| 语言 | 字符串 | 内 | 所支持的地盘列表 https://developers.google.com/ pickers/docs#i18n (英语) |
视图
| 选项 | 说明 |
|---|---|
| 医生 | 所有Google Drive文档类型. |
| 医生 图像 | 谷歌驱动相片. |
| DOCS IMAGES AND 视频 | Google驱动相片和视频. |
| DOCS 视频 | 谷歌驱动视频. |
| 文件 | 谷歌驱动文档. |
| 基金会 | 谷歌驱动文件夹. |
| 拖车 | 谷歌驱动绘图. |
| 形式 | Google Drive Forms. (原始内容存档于2018-10-21). |
| PDFS 系统 | PDF文件被存储在Google Drive. |
| 碎片 | 谷歌驱动电子表格. |
作者
承认
灵感, 代码片段