google-apps-script - 通过 Google Apps 脚本获取 Google Drive 中文件的下载链接
问题描述
我创建了如下脚本:
function myFunction() {
let u1 = Drive.Files.get('1234');
// console.log()
let u2 = DriveApp.getFileById('1234').getDownloadUrl();
let u3 = DriveApp.getFileById('1234').getUrl();
}
id 1234 的文件是 Google 驱动器中的电子表格。
我想要一个链接。
https://docs.google.com/spreadsheets/d/1234/export?format=xlsx
除非 id 没有改变,否则这个链接似乎是静态的。但是,我想知道一种使用文件对象的方法来获得此链接的方法。
我以为u2
有链接,但它变成了null
. 并且u3
是https://docs.google.com/spreadsheets/d/1234/edit?usp=drivesdk
u1
似乎有链接,我实际上可以通过
u1.exportLinks["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"];
这是获取链接的唯一方法吗?
解决方案
推荐阅读
- python - 如何在 Python 中使用库创建有效的 SAML 2.0 断言
- powershell - 在 PowerShell 中列出 Windows 文件夹权限时排除特定用户
- javascript - 如何在提升 require 语句之前运行代码?
- python - 如何更改多级索引/列 DataFrames 的 pyarrow 表列精度
- python - 根据另一个参数的值设置一个参数的默认值
- ansible - 当条件导致跳过时,无法在ansible循环中比较变量字符串
- ruby-on-rails - 转换错误:Jekyll::Converters::Markdown 在转换 '_posts/2020-10-31-bla.markdown' 时遇到错误
- python - Python列表中计算元素变化索引的最快方法
- javascript - 反应:如果语句为真,则禁用所有 TextField 包装器组件
- amazon-web-services - 每个查询消耗多少读/写容量?