2015-07-21 66 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

這是因爲您的谷歌應用程序管理員限制訪問與公衆共享驅動器文件。與您的管理員討論放鬆限制。我相信這種限制可以在組織層面進行設置,以便爲您制定一個例外。