【发布时间】:2014-04-21 09:46:49
【问题描述】:
如何使用 Google Apps 脚本从用户驱动器中检索文件?我试过了:
var fetchURL = 'file:///C://Users//Gigabyte//Pictures//file_name.JPG';
var image = UrlFetchApp.fetch(fetchURL).getBlob();
我尝试过使用转义字符而不是斜杠。
'file:%2F%2F%2FC:%2FUsers%2FGigabyte%2FPictures%2Ffile_name.JPG'
我尝试了不同的反斜杠和正斜杠变体。到目前为止没有运气。
或者我可能以错误的方式处理这个问题。也许我需要以其他方式获取文件 blob?
我确实找到了有关如何从用户驱动器中获取文件到网站的信息: Stackoverflow Understanding
但 Caja 似乎确实去除或阻止了正在定义的新 blob。
我在这个网站上找到了这个代码:HTML5 Rocks
// Check for the various File API support.
if (window.File && window.FileReader && window.FileList && window.Blob) {
alert('Great success! All the File APIs are supported.');
} else {
alert('The File APIs are not fully supported in this browser.');
}
当我在 Chrome 中从 Notepad++ 运行该代码时,它检查正常。当我在 Chrome 中的 Google Apps 脚本中运行该代码时,出现了问题。所以, 。 . .显然有一种上传文件的方法。它一直在发生。但我无法通过 Google Apps Script 中的 HTML 服务来实现。我可以触发 Google Apps 脚本 UI,它将文件从用户计算机上传到我的 Google 驱动器。我想这是我唯一的选择。我不知道如何在 HTML 页面中嵌入 UI。
【问题讨论】:
标签: url upload google-apps-script fetch