I prepared a simple Google Apps Script with Upload form to allow my friend without google account uploading some files (different types - pics, docx, png etc. ; rather small files - under 10MB)
function doGet(e) {
return HtmlService.createHtmlOutputFromFile('form.html');
}
function uploadFiles(form) {
try {
var mainFolder = "Tmp_Uploads";
var folder = DriveApp.getFoldersByName(mainFolder).next();
var file = folder.createFile(form.myFile);
return "File uploaded successfully " + file.getUrl();
} catch (error) {
return error.toString();
}
}
Mechanism works -> after uploading file shows in my "Tmp_Uploads" folder in Google Drive. But when I download it to my PC -> file is broken.
I tested it with .jpg, .png, .doc and all of them are broken - cannot open them (they also have different size than original one).
When I upload simple .txt file -> it works fine.
Quastions:
- What is wrong?
- Can I somehow recover file which was uploaded with above mechanism? Decode it after downloading to PC or postprocess to be able to open it?
Cheers and thanks in advance!