Send ImagePicker.AfterPicking to Google Drive/Google Spreadsheet

Hi!
I am doing a forms on my app where the user takes a photo from his gallery and sends it to me. What I want is to receive that photo through Google Drive/ Google Spreadsheet but I can't make it work. For now, I am following this example: https://groups.google.com/forum/#!topic/mitappinventortest/liWppNXqHXM
It perfectly works for the Camera function. However, when I try it with the ImagePicker.Selection it doesn't work properly. It shows me this error screen:


I would appreciate your help! I am creating this in order to meet again pets with their owners :slight_smile:

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

Yes, sure! I really appreciate your fast answer!
Here they are the blocks:


I also append the php that I am using in order to receive the photos on a Google Spreadsheet, it doesn't work though.

function doGet(e) {
 return message("Error: Please Try Again");
    
}

function doPost(e) {
  if (!e.parameters.filename || !e.parameters.file || !e.parameters.imageformat) {
    return message("Error: Please Try Again");
  } else {
    var imgf = e.parameters.imageformat[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;
    if (mime) {
      var data = Utilities.base64Decode(e.parameters.file, Utilities.Charset.UTF_8);
      var blob = Utilities.newBlob(data, mime, e.parameters.filename);
      
      var Bitmap = DriveApp.getFolderById('1-dlXIhoxIMX1vAYGurPGWxtMEheQMd4G').createFile(blob).getId();
      var name = e.parameters.filename[0];
      var viewurl = "https://drive.google.com/uc?export=view&id=" + Bitmap;
      
    var ss = SpreadsheetApp.getActive();
      var sh = ss.getSheets()[0];
      sh.appendRow([Bitmap,name,viewurl]);
     
      return message("Success: Image Uploaded and Data Saved");
    } else {
      return message("Error: Please Try Again");
    }
  }
}

function message(msg) {
  return ContentService.createTextOutput(msg);
}

This part:

was only designed to cope with AI2 in different locales where a jpg is a jpeg, it was not designed to convert from one image format to another. This may be the issue if you are selecting bmp files using the image picker ?

You might also want to use DO IT to check the file paths from the image picker as they pass through the routine to ensure they are correct

Yes, where it sais "bmp" it was originally saying "peg". I changed it because the following error appears me every time I try to send the photo to Google Drive. So, in order to fix the error I tried to change that, but it still doesn't work... !


I don't know how to get rid of this error, I may arrange the php code appended to the Google Spreadsheet. Anyhow, images are not being sended to my Google Drive folder neither...

  1. It is not php code, it is javascript - well google's version of javascript
  2. Have you properly updated your script?

1 Open the script project
2 Go to Publish
3 Deploy as Web App
4 Project version: - select New from the dropdown
5 Execute the app as: your google account address (email)
6 Who has access to the app: Anyone, even anonymous
7 Press the Update button

You have to do this EVERY TIME you change your script

try to find out, when exactly you get that error...
disable most of the blocks and start with only resizing the image without sending it
in case this works, then activate a few more blocks until you know, what causes the error...

Taifun

Hi! This is the specific part that triggers the error. Surprisingly, the block "set global vImageFormat" works perfectly though...


With the option DO IT, it appears the following error:
I've tried to remove the -7 math operation, like this:

And i'm getting this error now...

So, I eliminate the block "length" like this...

And it appears me the following error:

I guess the only thing that is not working is the length part of the block... How could I fix it?

I've made it! It was simpler than I thought...


Thank you for helping us!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.