Is it possible to upload image from camera to google datasheet?

what happen if more than 2 images? what method should I use got any example?

function doGet(e) {

return message("Error: Please Try Again");

   

}

 

function doPost(e) {

 if (!e.parameters.filename || !e.parameters.file || !e.parameters.imageformat ||!e.parameters.filename2 || !e.parameters.file2 || !e.parameters.imageformat2 ) {

   return message("Error: Please Try Again");

 } else {

   var imgf = e.parameters.imageformat[0].toUpperCase();

   var imgf2 = e.parameters.imageformat2[0].toUpperCase();

   var mime =

       (imgf == 'BMP')  ? MimeType.BMP

     : (imgf == 'GIF')  ? MimeType.GIF

     : (imgf == 'JPEG') ? MimeType.JPEG

     : (imgf == 'JPG')  ? MimeType.JPEG

     : (imgf == 'PNG')  ? MimeType.PNG

     : (imgf == 'SVG')  ? MimeType.SVG

     : false;

    

  var mime2 =

       (imgf2 == 'BMP')  ? MimeType.BMP

     : (imgf2 == 'GIF')  ? MimeType.GIF

     : (imgf2 == 'JPEG') ? MimeType.JPEG

     : (imgf2 == 'JPG')  ? MimeType.JPEG

     : (imgf2 == 'PNG')  ? MimeType.PNG

     : (imgf2 == 'SVG')  ? MimeType.SVG

     : false;

   if (mime && mime2) {

   

     var data = Utilities.base64Decode(e.parameters.file, Utilities.Charset.UTF_8);

     var blob = Utilities.newBlob(data, mime, e.parameters.filename);

     var data2 = Utilities.base64Decode(e.parameters.file2, Utilities.Charset.UTF_8);

     var blob2 = Utilities.newBlob(data2, mime, e.parameters.filename2);

          

      var imageID = DriveApp.getFolderById('1XgIfdcnScc-vK078zbfZQaC6OK7yPVjp').createFile(blob).getId();

      var imageID2 = DriveApp.getFolderById('1XgIfdcnScc-vK078zbfZQaC6OK7yPVjp').createFile(blob2).getId();

   

     var name = e.parameters.filename[0];

     var name2 = e.parameters.filename2[0];

      var viewurl = "https://drive.google.com/uc?export=view&id=" + imageID;

      var viewurl2 = "https://drive.google.com/uc?export=view&id=" + imageID2;

       var foto = "=image(\"https://docs.google.com/uc?export=download&id=" + imageID +"\")";

       var foto2 = "=image(\"https://docs.google.com/uc?export=download&id=" + imageID2 +"\")";

      

    var ss = SpreadsheetApp.openById('15O_XHDYRrIPKOvukGJKFPtV_JmHaPw6m8UhJpoXKR4s');

        

      var sh = ss.getSheets()[0];

      

      sh.appendRow([name,viewurl,foto,name2,viewurl2,foto2]);

      

      return message("Success: Image Uploaded and Data Saved");

    } else {

      return message("Error: Please Try Again");

    }

  }

}

function message(msg) {

  return ContentService.createTextOutput(msg);

}

is this google script programming correct?

You keep moving the goalposts...first it was image from app to a google sheet, then you wanted to upload two images, now to upload more than two images.

Please define your precise and final requirements.

I would also recommend that you take a few steps back, and get one of the guides your are following (your seem to be using @ three different ones) to work. Then you can develop on from there.

I didnt get what you said, btw what is goalposts mean?

It is just a phrase to imply you are changing your requirements. He is asking you to give a precise requirement.


still cannot work, sir can you help me check what is the problem with? I already use the Apps script that you edited just now but still fail. Nothings uploaded in the datasheet.


is that the problem with my mit app inventor blocks?


this is the designer

Could I suggest that you start with something simpler, then once you understand how that works, we can move on to the more advanced Idea of displaying your image/s in your spreadsheet.

I try that before already upload somethings to googledrive. But now is to upload 2 images to spreadsheet, can you help me spot what is my mistake? that all. I got no time already, this work need to be done as soon as possible. Appreciate if you can help thanks

You have not followed any of my previous advice.

You are not using the correct method or script, which I provided in my first response.

I already use the script which edited by you but still failed now is that my mit app inventor block programming is wrong? especially when at upload there? where I upload 2 images together? is that that part is wrong?

I have not provided any edited script....

Yes this is wrong, you need to upload one at a time.

you edit my google apps script right at above there?

this one you edited?


is this programming upload 2 picture in the same time? if no can I use this idea?

I have already told you three times to not do it like that, and provided you with a blocks solution.

okok understood just asking if too many images can I use list view then call them in order when uploading?

Upload your images one by one...

Here is an example to download images one by one... you might want to use the same logic and adjust it to your needs

Taifun