I'm passing data to the google application wich published on the web using Post method. Here is the code of the sever side:
function doPost(e) {
var params, result, responce;
if(typeof e !== 'undefined')
params = (e.parameters);
if (params['type'] == 'get') {
//do the get;
}
else {
try {
result = reformat_src(e.parameters);
responce = process_result(result);
}
catch(e) {
return ContentService.createTextOutput(JSON.stringify(e));
}
}
return ContentService.createTextOutput(JSON.stringify(responce));
}
function reformat_src(request) {
var prop, obj;
obj = {};
for (prop in request) {
obj[prop] = request[prop][0];
}
return obj;
}
In process_result function I'm trying to create an image file on google drive
function process_result(result) {
var folder;
folder = DriveApp.getRootFolder();
folder.createFile('test', result['blob'], MimeType.PNG);
}
I know that result['blob'] contains the png file that I've got with
var reader = new FileReader();
reader.readAsBinaryString(f);
But I failed to create a file. Does anybody know how to create an image file having data from FileReader? I can pass to GAS any of type:
readAsBinaryString
readAsText
readAsDataURL
readAsArrayBuffer
Thank you in advance!