How to create image file on Google drive having BinaryString or any of FileReader options
12:37 11 Oct 2015

I'm passing data to the Google application which 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!

javascript google-apps-script filereader