Google Drive API 範例
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本節提供 Google Drive API 的範例。
如需 Drive API 的簡介影片,請參閱 Drive API 影片庫。
Google 在 GitHub 上提供下列範例。您可以分支這些存放區,並將程式碼做為自己專案的參考。
Google Picker
Google Picker 程式碼範例說明如何使用圖片選取器或上傳頁面,使用者可以從網路應用程式中的按鈕開啟這些工具。
如要查看或下載來源,請前往 GitHub 存放區的 Google Picker。
使用 Quickeditors 開啟及儲存檔案
這個 Quickeditors 程式碼範例說明如何使用 Drive API 開啟及儲存檔案。
每個雲端硬碟平台專屬範例都反映單一範例應用程式:文字編輯器 (稱為 Quickeditor),可編輯 MIME 類型為 text/*
的雲端硬碟檔案。網頁版實作了兩個基本的 Google 雲端硬碟用途:
這兩種用途的流程相似,使用者從建立選單或已註冊 MIME 類型的檔案內容選單中選取應用程式後,雲端硬碟會將使用者重新導向至該應用程式。
如要查看或下載來源,請前往 GitHub 存放區的 Drive Quickeditors。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-29 (世界標準時間)。
[null,null,["上次更新時間: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)"]]