I'm trying to create a google form in which I ask people to upload a zip file:
<label for="uploadZip"> Please submit your response in a single zip archive.* </label>
<input type="file" name="uploadZip" required />
In .gs
script I tried:
function doGet(e) {
return template = HtmlService.createHtmlOutputFromFile('form.html');
return template.evaluate().setSandboxMode(HtmlService.SandboxMode.IFRAME);
}
function uploadFiles(form) {
try {
var rootID = "MyRootID";
var root = DriveApp.getFolderById(rootID);
var directory = "AllUploadZips";
var folders = root.getFoldersByName(directory);
if (folders.hasNext()) {
folder = folders.next();
} else {
folder = root.createFolder(directory);
}
var foldername = form.myLastName + ", " + form.myFirstName;
var myFolder = folder.createFolder(foldername);
var zip = form.uploadZip;
var file_zip = myFolder.createFile(zip);
} catch (error) {
return error.toString();
}
}
This will save the zip file in "AllUploadZips/myLastName, myFirstName/"
in my drive. However the zip is broken with the following error message:
$ unzip myZip.zip
Archive: myZip.zip
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of myZip.zip or
myZip.zip.zip, and cannot find myZip.zip.ZIP, period.
The script works fine if I had instead uploaded a .txt
or .pdf
. It's just having problem with zip files. Does anyone have any idea what's going on? Thanks a lot!