Created
October 25, 2016 11:21
-
-
Save tm8r/cc25f6f4697803fecbd5daf43c6f0e2f to your computer and use it in GitHub Desktop.
DriveFileCopy
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) { | |
var fileId = e.parameter.fileId; | |
Logger.log("fileId:"+fileId); | |
if (!fileId){ | |
Logger.log("invalid fileId."); | |
return HtmlService.createHtmlOutput(false); | |
} | |
var file = DriveApp.getFileById(fileId); | |
if (!file){ | |
Logger.log("file is not found."); | |
return HtmlService.createHtmlOutput(false); | |
} | |
var parents = file.getParents(); | |
var parent; | |
while (parents.hasNext()) { | |
parent = parents.next(); | |
Logger.log(parent.getName()); | |
break; | |
} | |
if(!parent){ | |
} | |
var fileName = file.getName() + "_" + Utilities.formatDate( new Date(), 'JST', 'yyyy_MM_dd_HHmmss'); | |
file.makeCopy(fileName, parent); | |
return HtmlService.createHtmlOutput(true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment