I am trying to use FileReader.readDataAsUrl() to send a blob object in a JSON file. But I keep getting the error Reference Error: "FileReader" is not defined. Is there a way that I need to implement it since I am using Apps Script? I see an issue someone had where they set their sandbox to IFRAME and it fixed it, but everywhere I see says that is the default mode now. The function where i actuallly initialize FileReader currently, is in buildPackage().
function doGet() {
var response = getJSON();
console.log("SENT DATA");
return ContentService.createTextOutput(response).setMimeType(ContentService.MimeType.JSON);
}
function getJSON() {
console.log("BUILDING JSON");
var folder = DriveApp.getFolderById("1WT4KihCV5kXvmnO80Z9lPuvjoEH5vR63").getFiles();
var files = {};
while (folder.hasNext()) {
var file = folder.next();
var fileName = file.getName();
var filePackage = buildPackage(file);
files[fileName] = filePackage;
console.log(filePackage);
}
return JSON.stringify(files);
}
function buildPackage(file) {
//build the package to be sent holding the downloadurl, mime type, and blob
var package = {};
var fileReader = new FileReader();
package["downloadUrl"] = file.getDownloadUrl();
package["mime"] = file.getMimeType();
var blob = file.getBlob();
package["blob"] = blob;
return package;
}
Here is my relevant code, I have my webapp pushed as accessible to anyone with the link, and runs as me. I removed any parts of my script using FileReader other than when i initialize it, and I still hit the error. I feel like I'm just missing something basic but i can't find anything online thats helped so far.