2015-07-21 59 views
1

我在网上复制了一个应用程序脚本,允许用户通过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(); 
    } 

} 
+0

脚本文件在哪里?您是通过“管理站点”控制台直接在网站上创建脚本,还是托管在驱动器中? –

回答

0

如果你想每个人,甚至当他们浏览您的网站未在他们的谷歌帐户登录的学生,有上传文件(=使用脚本)的能力,那么你应该从部署菜单中更改Execute app asuser accessing the appMe,然后您将可以选择Anyone, even anonymous

问题是,未登录Google帐户的用户被标记为匿名。

+0

并非如此。看到我的答案。 –

+0

@ZigMandel,是的,你可能正确地考虑到“我的域名中的任何人”选项,但是为了实现他所寻找的结果,他仍然必须执行我后面描述的操作。我的意思是设置'任何人甚至匿名'访问。 –

+0

是的,他知道这一步,因此他看到选项“任何人在我的域名” –

0

这是因为您的谷歌应用程序管理员限制访问与公众共享驱动器文件。与您的管理员讨论放松限制。我相信这种限制可以在组织层面进行设置,以便为您制定一个例外。