Google apps script 通过Google应用程序脚本获取Google drive中文件的下载链接
我创建了一个脚本,如下所示:Google apps script 通过Google应用程序脚本获取Google drive中文件的下载链接,google-apps-script,google-sheets,google-drive-api,Google Apps Script,Google Sheets,Google Drive Api,我创建了一个脚本,如下所示: 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 drive中的电子表格 我想要一个链接 https://doc
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 drive中的电子表格
我想要一个链接
https://docs.google.com/spreadsheets/d/1234/export?format=xlsx
除非id不变,否则此链接似乎是静态的。
不过,我想知道一种使用file对象的方法来创建此链接的方法
我以为u2
有链接,但它变成了null
。
而u3
ishttps://docs.google.com/spreadsheets/d/1234/edit?usp=drivesdk
u1
似乎有链接,我实际上可以通过
u1.exportLinks["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"];
这是获取链接的唯一方法吗?关于
我想知道一种使用file对象的方法来获取此链接的方法。
,不幸的是,现在没有像https://docs.google.com/spreadsheets/d/1234/export?format=xlsx
在这种情况下,https://docs.google.com/spreadsheets/d/${fileId}/export?format=xlsx
是否使用文件ID?顺便说一下,aboutu1似乎有链接,在本例中,URL类似于https://docs.google.com/spreadsheets/export?id=###&exportFormat=xlsx
。这是你想要的URL吗?