【发布时间】:2021-05-14 12:56:19
【问题描述】:
我有以下代码,我想在 App Script 中使用 Drive v3
function myFunction() {
let id = "<YOUR ODS FILE ID>";
let file = DriveApp.getFileById(id);
let fileBlob = file.getBlob();
newFile = {
name: "New File",
mimeType: "application/vnd.google-apps.spreadsheet"
}
try{
Drive.Files.create(newFile, fileBlob);
}catch(e){
Logger.log("Error");
Logger.log(e);
}
}
但是,默认情况下,谷歌应用脚本只提供 v2。文档似乎并不容易直接在 App Script 中进行此迁移。
如何在此代码中直接在 google 应用脚本中使用 Drive v3?
【问题讨论】:
-
Google Drive 的 GAS built-in 和 advanced service 都利用了 API 的 V2。要使用 V3,您需要直接使用
Url Fetch向 REST API 发出请求。 -
@TheAddonDepot 你能帮我如何使用 Drive v3 和 url fetch 吗?
标签: google-apps-script google-drive-api