Hi - am a newbie. Tried some tutorials and made basic app. I saw this solution by TimAi2 https://groups.google.com/forum/#!topic/mitappinventortest/liWppNXqHXM and am trying to replicate his solution.
The App basically takes a picture and the Geolocation and sends data to a googlesheet. The App part works fine, the picture is taken, the coordinates are shown on the APP but when uploading getting an error. It seems the error must be in googlescript.
I copied the script (below) exactly. I made the google drive folder shared and accessible by anyone.
I changed the Folder ID to the images folder.
I also tried sending just the location data without the image.
In the MIT App I changed the googlescript location - this is clearly working as the Googlescript is being executed.
The googlesheet is itself shared with anyone on the web. There is only one tab Sheet1
What am I doing wrong?
Raj
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('1wolWAcF6_3YUNFRq75GAsZ7Y1Bk0Ttdf').createFile(blob).getId();
var lat = e.parameters.lat[0];
var lon = e.parameters.lon[0];
var add = e.parameters.address[0];
var name = e.parameters.filename[0];
var viewurl = "https://drive.google.com/uc?export=view&id=" + imageID;
var ss = SpreadsheetApp.getActive();
var sh = ss.getSheets()[0];
sh.appendRow([lat,lon,add,imageID,name,viewurl]);
return message("Success: Image Uploaded and Data Saved");
} else {
return message("Error: Please Try Again");
}
}
}
function message(msg) {
return ContentService.createTextOutput(msg);
}[upload_CameraImage_Location_Data_GD (1).aia|attachment](upload://oErojmrAKBfakPNN0cp0q33sX1O.aia) (36.4 KB)
Yes you will, because the script is set to only work with doPost(e) - so you have to run it from the app or test with “Postman”.You would also need to be adding all the parameters to the end of the url.
What response content are you getting from the app? (You can edit all the error messages in the script so that you know which one is which - but don’t forget to republish the web app to a new version)
Hi Tim - thanks. Yes I did that already. I edited the error messages slighly - so can tell which one.
When I run the app on the mobile - takes the pic. shows the location and upload button.
when I press the Upload button - quite quickly get the Error Message in App Inventor -Error:Pleas TRy Again - in Red -
Sorry - ignore - I was being stupid - In Google drive access was not set correctly - and the link was missing a digit. For anyone else - Access needs to be “Any one on Internet can find and edit”.
Thanks Tim for your help and patience.
If the script is running as “you” (your google account) and “you” also own the spreadsheet and the folder, the google drive/sheet access permissions can be tighter - even “private only me”. Try it.
You will need to assess the image taken on the camera: is it landscape or portrait, resolve this, then upload to google drive. Try using Taifun’s Image extension.
Si se utizo esa extension el tema esta es que el error esta que el app de camara que viene por defecto lo toma la foto y te da como resultado inclidado a la izquierda.
Estoy utilizando el app Line Camara que puse por establecido para que tome las foto y si se muestra
As you have seen, different devices give back different information, and handle their camera images in different ways. It would also be difficult to programmatically set the orientation correctly with a square image. You may have to present a preview to your user in the app, leaving it for them to decide if rotation is required, prior to uploading to google drive, if you can figure out which ones will be rotated on google drive. (Some devices return the image rotated 180 degrees!
Me referia al tamaño de la imagen porque cuando la imagen es mas grande el aplicativo demora en el proceso de enviar los datos y cuando la imagen es pequeña se pierde la resolución
Para el tema de la imagen el tamaño en el maxwidth y el maxheight
Cual seria el recomendable.
Maxwidth :600
Maxheigth: 400
Aumentar las unidades de medida
Y si es asi cuanto seria lo recomendable
Saludos