Post Image File from App Inventor to Google Apps S

2019-06-10 02:47发布

问题:

I have posted image file from App Inventor to Google Apps Script web app.

Attached App inventor Blocks for Image Upload
App Inventor Blocks

Below is Code for Google App Script WebApp for Processing Post request, so that Image in post body can be saved to google drive

function doPost(eventInfo) {

  MyLog("doPost", "eventInfo", eventInfo.parameters);

if(eventInfo.parameter.type === 'test') {

var destination_id = "0B63z7K35zZN9ZzhEc1NaQV9XaDA";
var img = eventInfo.postData.contents;
var file = Utilities.newBlob(img);
var contentType = "image/jpeg";

MyLog("Test", "check", contentType);

var destination = DriveApp.getFolderById(destination_id);
var driveFile = destination.createFile("Test",file,"image/jpeg"); 
var fileName = driveFile.getName();
MyLog("doPost", "check", fileName);
 }

How to process the postData.contents to save the image file to Google Drive