我在网上复制了一个应用程序脚本,允许用户通过Google网站直接将文件上传到我的Google云端硬盘中的文件夹,因为我是老师,而不是程序员。无法设置“任何人”访问我的脚本
我遵循程序员设置的指示,我授权了应用程序,但是当我想要“部署为web应用程序”时,当我选择“谁有权访问应用程序:”时,只有选项可用是“我自己”和“我的域中的任何人”,但“任何人”不可用。
这对我很重要,因为我的学生打算上传文件给我,其中很多人没有GMail或同一个域中的帐户。我不想通过仅使用日常使用的个人电子邮件帐户登录另一个帐户来让他们更难。
在Google脚本更改之前,我能够运行一个非常类似的脚本。
预先感谢您!
/* The script is deployed as a web app and renders the form */
function doGet(e) {
return HtmlService.createHtmlOutputFromFile('form.html')
.setSandboxMode(HtmlService.SandboxMode.NATIVE);
// This is important as file upload fail in IFRAME Sandbox mode.
}
/* This function will process the submitted form */
function uploadFiles(form) {
try {
/* Name of the Drive folder where the files should be saved */
var dropbox = form.myName + " " + form.myEmail;
var folder, folders = DriveApp.getFoldersByName(dropbox);
/* Find the folder, create if the folder does not exist */
if (folders.hasNext()) {
folder = folders.next();
} else {
folder = DriveApp.createFolder(dropbox);
}
/* Get the file uploaded though the form as a blob */
var blob = form.myFile;
var file = folder.createFile(blob);
/* Set the file description as the name of the uploader */
file.setDescription("Uploaded by " + form.myName);
/* Return the download URL of the file once its on Google Drive */
return "File uploaded successfully " + file.getUrl();
} catch (error) {
/* If there's an error, show the error message */
return error.toString();
}
}
脚本文件在哪里?您是通过“管理站点”控制台直接在网站上创建脚本,还是托管在驱动器中? –