gpt4 book ai didi

google-apps-script - 使用 DriveApp 访问共享驱动器

转载 作者:行者123 更新时间:2023-12-03 16:22:48 25 4
gpt4 key购买 nike

我正在尝试使用谷歌应用程序脚本在共享驱动器中创建一个新文件,以便使用共享驱动器的其他人也可以访问该文件。 DriveApp 上是否有允许我这样做的方法?

我曾尝试使用 DriveApp.getFoldersByName 但这仅适用于我私有(private)驱动器中的根文件夹。

最佳答案

您需要使用 Advanced Drive Service基于Drive API

方法Drive.Drives.insert允许您指定驱动器 ID。

Keep in mind that for shared drives, you need to specify the additional parameter supportsAllDrives: true. Also, you need to enable the Advanced Drive Service before using.



样本:
function myFunction() {  
var optionalArgs={supportsAllDrives: true};
var resource = {
title: 'mySharedFile',
mimeType: 'application/pdf',
parents:[{
"id": "ID OF THE SHARED DRIVE"
}]
}
Drive.Files.insert(resource, null, optionalArgs)
}

关于google-apps-script - 使用 DriveApp 访问共享驱动器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58170053/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com