【发布时间】:2019-05-24 17:46:15
【问题描述】:
我目前在 Google Sheet 中有一个 Google App Script,它为我提供了一个文件夹的 URL,然后我可以使用它来下载。虽然这是一个额外的步骤,但我想删除,并直接获取压缩内容的 URL。
这是我的代码(谷歌应用脚本):
function downloadSelectedScripts() {
// ...
var scriptFiles = getScriptFiles(scriptFileNames)
var tempFolder = copyFilesToTempFolder(scriptFiles)
Browser.msgBox(tempFolder.getUrl())
}
function copyFilesToTempFolder(files) {
var tempFolder = DriveApp.getFolderById(FOLDERS.TEMP)
var tempSubFolder = tempFolder.createFolder('download_' + Date.now())
for (var i in files) {
var file = files[i]
file.makeCopy(file.getName(), tempSubFolder)
}
return tempSubFolder
}
【问题讨论】:
-
我为我糟糕的英语水平道歉。可以问一下
I would like to remove, and get the URL of the zipped content directly.的详细情况吗? -
@Tanaike tempFolder.getUrl() 给了我驱动器文件夹的 URL。当我到达这个 URL 时,我必须单击文件夹上的“下载”,然后它会以 zip 格式下载。我想跳过这一步,直接获取ZIP文件的url。
-
试试
webContentLink -
@Dave 感谢您的回复。不幸的是,我还不能理解你的目标。对不起。那我能问一下你的回复吗? 1.
click "Download" on the folder是什么意思? 2、skip this step中的this step是什么? 3. 您想将文件夹中的所有文件下载为 zip 文件。我的理解正确吗? -
@pa1.Shetty 我刚刚在文件夹上尝试了googleapis.com/drive/v2/files/folderId,但响应不包含 webContentLink
标签: google-apps-script google-drive-api