Post Image File from App Inventor to Google Apps Script

▼魔方 西西 提交于 2019-12-08 10:20:36

问题


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

来源:https://stackoverflow.com/questions/45180689/post-image-file-from-app-inventor-to-google-apps-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!