Created
April 17, 2016 21:04
-
-
Save justinmoon/c15e594f5e989191fc52855fc9695a3e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doGet(e) { | |
// All Udacity spreadsheet are accessible by agent (the student) running this script | |
var fileId = e.parameters.fileId; | |
// Get the file, make copy with same name, and grab new URL | |
var existingFile = DriveApp.getFileById(fileId); | |
var fileName = existingFile.getName(); | |
var copiedFile = existingFile.makeCopy(fileName); | |
var newUrl = copiedFile.getUrl(); | |
// Return HTML containing | |
// - A form that navigates user to new file's URL | |
// - A script which submits the form automatically | |
var html = "<form action='" + newUrl + "' method='get' id='link'></form>" + | |
"<script>document.getElementById('link').submit();</script>"; | |
return HtmlService.createHtmlOutput(html); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment