【发布时间】:2019-11-10 12:38:42
【问题描述】:
我想使用 Google Script 和 Python 将文件上传到 Google Drive。
我不想使用 API 执行此操作,因为它使用 JSON 文件并请求 Google 帐户的密码。
我想从没有 JSON 文件且不请求谷歌帐户的 Python 文件发送。
我想在谷歌脚本中创建一个脚本,将文件上传到网站。
我找到了如何使用 html 来做到这一点:
function saveFile(data,name,folderName) {
var contentType = data.substring(5,data.indexOf(';'));
var file = Utilities.newBlob(
Utilities.base64Decode(data.substr(data.indexOf('base64,')+7)),
contentType,
name
); //does the uploading of the files
DriveApp.getFolderById(childFolderIdA).createFile(file);
}
但是我没有找到如何用 python 来做。
如何将带有文件的文件发送到此代码?
【问题讨论】:
-
如果您未通过身份验证,您还想如何发送文件? Google 需要知道您是谁,除非您希望有人向您的帐户发送垃圾邮件并使用您所有的免费 Google 云端硬盘空间...
-
我相信这就是你要找的东西:developers.google.com/drive/api/v3/quickstart/python
标签: python google-apps-script web-applications google-drive-api