但是,我正在嘗試將檔案上傳到共享驅動器;如果我在選項引數中設定了我的 drive_id,它仍然使用我的默認驅動器,即“我的驅動器”。
我究竟做錯了什么?(drive_id 只是一個例子)
google_file = Google::Apis::DriveV3::File.new(drive_id: "123456789", name: 'test.txt')
drive = Google::Apis::DriveV3::DriveService.new
source_file Tempfile.new("text.txt")
drive.create_file(google_file, upload_source: file)
我也嘗試在創建檔案時設定 parent_ids 并且也遇到錯誤。見下文:
Google::Apis::DriveV3::File.new(drive_id: '123456789', name: 'test.txt', parents: ['123456789'])
results in:
Google::Apis::ClientError: notFound: File not found: 123456789.
在這里的任何幫助將不勝感激!
uj5u.com熱心網友回復:
我相信你的目標如下。
- 您想使用 Drive API v3 將檔案上傳到共享云端硬碟中的特定檔案夾。
- 您想使用 googleaspif ro ruby?? 來實作這一點。
在這種情況下,如何進行以下修改?
修改后的腳本:
google_file = Google::Apis::DriveV3::File.new(name: 'test.txt', parents: ['###'])
drive = Google::Apis::DriveV3::DriveService.new
drive.create_file(google_file, upload_source: "text.txt", supports_team_drives: true)
- 在這里,請將檔案夾 ID 設定為
###ofparents: ['###']。如果要將檔案上傳到共享驅動器的根檔案夾,請將驅動器 ID 設定為###ofparents: ['###']。
筆記:
- 此修改假定您
drive可用于將檔案上傳到共享驅動器。請注意這一點。
參考:
- 檔案:創建
- 類:Google::Apis::DriveV3::DriveService
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/507583.html
標籤:红宝石 谷歌驱动API 谷歌驱动器共享驱动器 google-api-ruby 客户端
上一篇:為什么在這種情況下使用引數語法運算子“[”?AsLike""['i']""我用作RGSS、RPGMakerXP和win32api和ruby?
下一篇:如何遍歷哈希陣列?(紅寶石)
