App Inventor picture safe to google formula/spreadsheets

my name ist Ben. I have a problem to safe pictures from camera function of appinventor to google spreadsheets.
How can I safe the pictures of my app to a google sheet / formula?

I would be really happy if you can help me :slight_smile:

greetings Ben

HOWTO: Upload Image to Google Drive using base64 using Camera Image


1 Like

Hello Tim,

I read a lot of your solutions. Great work!
I would like to build an app like yours:

It don´t works with my settings…

  1. I downloaded your project: “upload_CameraImage_Locati”

  2. I created a new folder and a new spreadsheet (and did it public)

  3. I added in the spreadsheet a script with following code:

    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 imageID = DriveApp.getFolderById(‘1KeLyPsYujVN3DSLJ0nr2XdpQi93EvAkX’).createFile(blob).getId();
    // ID of my folder
    var lat =[0];
    var lon = e.parameters.lon[0];
    var add = e.parameters.address[0];
    var name = e.parameters.filename[0];
    var viewurl = “” + imageID;
    var ss = SpreadsheetApp.getActive();
    var sh = ss.getSheets()[0];
    return message(“Success: Image Uploaded and Data Saved”);
    } else {
    return message(“Error: Please Try Again”);
    function message(msg) {
    return ContentService.createTextOutput(msg);

  4. Change the script text in project .aia

  5. run the project.
    Camera works, but after upload “Error: Please Try Again”

Tim can you helb me please?What is wrong?..
Thank you :slight_smile:

You don’t show your PostText blocks (SendeText) ?

Hello Tim,

here the full block:

I just changed the web1.Url

Check that all of the variables (hole), especially the first three are correct (use Do It in Companion)

Also confirm that you have republished the script after changes, and that it is published as your google account and that anyone, even anonymous can access it.

Hello Tim,
thank you so much for support!

The solutions is the correct republishment:

I added a text box and it works that I can send the picture and the text to my google spreadsheet.
But one question more, how can I send just the text? The case could be that I dont need to take a picture.

greetings Ben

Then you would need a different script:

You are doing the same thing, but without the image

Hi Tim,

thank you for fast support.
I would like to work in one app/screen. So when I have a text and a picture then save both in spreadsheet (this works), when I have no picture then just save the text.
Can you help me with this case?

Thanks a lot!

I just did. Use a a different script. You can target the same sheet on the spreadsheet.

Hello Tim,

I would like to use the same button. I dont think that would be work with 2 scripts.

You can, just use some logic:

Button press
If no image then run script 1
run script 2 (for image)

Hi TIm,

I did it. Thank you!
I am sure I dont have the nicest way but it works :slight_smile:

Can you tell me where the pictures are located? I dont find the picture manually in my google drive.
I want to know where the space is used.

EDIT: Oh ok, i found it in the search. Can you tell me why the pictures are hidden?

greetings Ben

The image files are uploaded to the folder indicated in this line in the script/scripts:


I hadn’t noticed, but because you have been using the folder I presented in my demo, they are going to a shared folder on my google account. !!

You need to use your own folder, set the sharing accordingly, and change your script/scripts, then republish etc.

You can find the folder ID in the url address bar when you open the folder in Google Drive

hello Tim,

I think I use my folder and my spreadsheet.
this is the Folder ID of my account

Well that is where your images are then, someone used my folder this morning :wink:

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