Image upload to drive using TIMAI2 example

I'M USING AN EXAMPLE FROM MITAI2, DEMONSTRATING HOW TO UPLOAD IMAGE FROM APP INVENTOR APP TO GOOGLE DRIVE. THIS EXAMPLE ALSO USES A WEBAPP SCRIPT. I GET THE APP TO RUN, AND GET A UPLOAD SUCCESSFUL MESSAGE. i LOOK IN DRIVE FOLDER AND NOTHING IS THERE. ANY HELP WOULD BE GREATLY APPRECIATED.

[Mod Edit]

I'm using an example from TIMAI2, demonstrating how to upload image from app inventor app to google drive. This example also uses a webapp script. I get the app to run, and get a upload successful message. I look in drive folder and nothing is there. Any help would be greatly appreciated.

  1. No need to SHOUT!! - using ALL CAPS is considered rude on this forum.

  2. A link to the example? There are many ways.... This One ?

  3. Will need to see blocks and web app script

1 Like

Tim, here is the web script:

function doGet(e) {
return message("Error: no parameters in doGet");

}

function doPost(e) {
if (!e.parameters.filename || !e.parameters.file || !e.parameters.imageformat) {
return message("Error: Bad parameters in doPost");
} 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);
DriveApp.getFolderById('12vWo-gxzyLobsERdRZDIIkghuGSGuPwX').createFile(blob);
return message("Success this");
} else {
return message("Error: Bad image format");
}
}
}

function message(msg) {
return ContentService.createTextOutput(JSON.stringify({Result: msg })).setMimeType(ContentService.MimeType.JSON);
}

code blocks

I did fix the end of script by adding /exec

thank you!

I would recommend you first switch to this method:

https://ai2.metricrat.co.uk/guides/upload-any-file-to-google-drive-with-ai2

yeah, I tried that to. Didn't have any luck on that app either. Can I send you script and blocks data? thanks for the quick response.

Peace

my app I'm creating allows user to mark on a map where they caught their fish. I'm using runtime markers for locations and google sheets to record user name, date, fish weight...etc. I saw a couple examples that included camera function. If you know of any examples feel free to pass it along.

Sounds like you want this:

https://groups.google.com/d/msg/mitappinventortest/liWppNXqHXM/5Ht506yRBwAJ

So Tim, I tried another attempt to get your recommendation app going. only changes made were to script (folder location) and App inventor URL path. Can you help me get this going pls. Says upload successful.

Thanks

To confirm:

You have changed this to your own folder ID ?

and this to your own script url:

Your google apps script web app is bound to the spreadsheet ?

The web app script is published as "you" (your google account)
with access for "anyone, even anonymous" ?

You have correctly re-published the web app after any changes ?

Is any data written to the google sheet ?

Here is a link for how to do it (you might want to try this as an example):

Tim,

The Camera example worked flawlessly. I'm not sure why the others didn't. I hate not knowing the cause of error. I'll keep you and group posted on progress.

Thanks again,

Mark

Good news :+1:

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