Google 云端硬盘 API 示例
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本部分提供了 Google Drive API 的示例。
如需观看有关 Drive API 的入门视频,请参阅 Drive API 视频库。
Google 在 GitHub 上托管了以下示例。您可以派生这些代码库,并使用其中的代码作为自己项目的参考。
Google Picker
Google 选择器代码示例展示了如何使用图片选择器或上传页面,用户可以从 Web 应用中的按钮打开这些选择器或页面。
如需查看或下载源代码,请访问 GitHub 代码库中的 Google Picker。
使用 Quickeditor 打开和保存文件
此 Quickeditors 代码示例展示了如何使用 Drive API 打开和保存文件。
每个特定于 Drive 平台的示例都反映了一个示例应用:一个名为 Quickeditor 的文本编辑器,能够编辑 MIME 类型为 text/*
的 Drive 文件。网页版实现了两个基本的 Google 云端硬盘使用场景:
这两种使用情形的流程类似。当用户从“创建”菜单或具有已注册 MIME 类型的文件的上下文菜单中选择应用后,云端硬盘会将用户重定向到该应用。
如需查看或下载源代码,请访问 GitHub 代码库中的 Drive Quickeditors。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[],[],null,["# Google Drive API samples\n\nThis section provides samples for Google Drive API.\n\nFor introductory videos about Drive API, see the [Drive API\nvideo library](/workspace/drive/api/guides/videos).\n\nGoogle hosts the following samples on GitHub. You can fork these repositories\nand use the code as a reference for your own projects.\n\nGoogle Picker\n-------------\n\nThe [Google Picker code sample](/workspace/drive/picker/guides/sample) shows how to use\nan image selector or upload page that users can open from a button in a web app.\n\nTo view or download the source, visit\n[Google Picker](https://github.com/googleworkspace/browser-samples/tree/main/drive/picker)\non the GitHub repository.\n\nOpen and save files with Quickeditors\n-------------------------------------\n\nThis Quickeditors code sample shows how to open and save files with the\nDrive API.\n\nEach of the Drive platform-specific examples reflects a single\nsample app: a text editor, called a Quickeditor, capable of editing\nDrive files with the MIME type `text/*`. The [web\nversion](https://github.com/googleworkspace/drive-quickeditors/tree/main/web)\nimplements two fundamental Drive use cases:\n\n- [Integrate with Drive UI's \"New\" button](/workspace/drive/api/guides/integrate-create)\n- [Integrate with Drive UI's \"Open with\" context menu](/workspace/drive/api/guides/integrate-open)\n\nThe flow for both use cases is similar. Drive redirects a user to\nthe app after the user selects it from the create menu or the context menu of a\nfile with a registered [MIME type](/workspace/drive/api/guides/mime-types).\n\nTo view or download the source, visit [Drive\nQuickeditors](https://github.com/googledrive/web-quickeditor) on the GitHub\nrepository.\n\nRelated topics\n--------------\n\n- [The Google Picker API](/workspace/drive/picker/guides/overview)\n- [Drive UI integration overview](/workspace/drive/api/guides/about-apps)"]]