進階雲端硬碟服務
雲端硬碟進階服務可讓您在 Apps Script 中使用 Google Drive API。這個 API 與 Apps Script 的內建雲端硬碟服務非常相似,可讓指令碼在 Google 雲端硬碟中建立、尋找及修改檔案和資料夾。在大多數情況下,內建服務的使用方式較為簡單,但這項進階服務提供一些額外功能,包括存取自訂檔案屬性,以及檔案和資料夾的修訂版本。
參考資料
如要進一步瞭解這項服務,請參閱 Google Drive API 的參考文件。與 Apps Script 中的所有進階服務一樣,進階 Google 雲端硬碟服務會使用與公開 API 相同的物件、方法和參數。詳情請參閱「如何判斷方法簽章」。
如要回報問題或尋求其他支援,請參閱 Drive API 支援指南。
程式碼範例
本節的程式碼範例使用 API 的 第 3 版。
上傳檔案
以下程式碼範例說明如何將檔案儲存至使用者的 Google 雲端硬碟。
列出資料夾
以下程式碼範例說明如何列出使用者 Google 雲端硬碟中的頂層資料夾。請注意,您必須使用網頁權杖才能存取完整的結果清單。
列出修訂版本
以下程式碼範例說明如何列出特定檔案的修訂版本。請注意,部分檔案可能會有多個修訂版本,因此您應使用網頁符記存取完整的結果清單。
新增檔案屬性
以下程式碼範例會使用 appProperties
欄位,將自訂屬性新增至檔案。自訂屬性只有指令碼可見。如要在檔案中新增其他應用程式也能看到的自訂屬性,請改用 properties
欄位。詳情請參閱「新增自訂檔案屬性」。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-12-21 (世界標準時間)。
[null,null,["上次更新時間:2024-12-21 (世界標準時間)。"],[[["The advanced Drive service in Apps Script provides more features than the built-in service, like access to custom file properties and revisions."],["This advanced service requires enabling before use and mirrors the functionality of the Google Drive API."],["Code samples demonstrate how to upload files, list folders and revisions, and add custom properties to files in Google Drive using this service."],["The provided samples utilize version 3 of the Google Drive API and illustrate common Drive operations within Apps Script."],["For comprehensive details, refer to the Google Drive API reference documentation and support guide."]]],[]]