Skip to content

Instantly share code, notes, and snippets.

@pizzacat83
Created March 6, 2019 14:20
Show Gist options
  • Save pizzacat83/30ec2220e53de7d1ef711340f2f25ff3 to your computer and use it in GitHub Desktop.
Save pizzacat83/30ec2220e53de7d1ef711340f2f25ff3 to your computer and use it in GitHub Desktop.
const restoreItem = ({ id, isFolder }: { id: string; isFolder: boolean }): void => {
if (isFolder) {
throw new Error('Not implemented');
} else {
const deletedFile = DriveApp.getFileById(id);
if (deletedFile.isTrashed()) {
const newFile = deletedFile.makeCopy(deletedFile.getName());
const parents = deletedFile.getParents();
while (parents.hasNext()) {
const parent = parents.next();
parent.addFile(newFile);
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment