我在網上覆制了一個應用程序腳本,允許用戶通過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();
}
}
腳本文件在哪裏?您是通過「管理站點」控制檯直接在網站上創建腳本,還是託管在驅動器中? –