Hello,
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
greetings Ben
Hello,
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
greetings Ben
Hello Tim,
I read a lot of your solutions. Great work!
I would like to build an app like yours: https://groups.google.com/d/msg/mitappinventortest/liWppNXqHXM/5Ht506yRBwAJ
It donĀ“t works with my settingsā¦
I downloaded your project: āupload_CameraImage_Locatiā
I created a new folder and a new spreadsheet (and did it public)
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 = 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);
}
Change the script text in project .aia
run the project.
Camera works, but after upload āError: Please Try Againā
Tim can you helb me please?What is wrong?..
Thank you
You donāt show your PostText blocks (SendeText) ?
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
else
run script 2 (for image)
Hi TIm,
I did it. Thank you!
I am sure I dont have the nicest way but it works
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:
DriveApp.getFolderById(ā1KeLyPsYujVN3DSLJ0nr2XdpQi93EvAkX'.createFile(blob).getId();
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.
DriveApp.getFolderById(ā1KeLyPsYujVN3DSLJ0nr2XdpQi93EvAkXā.createFile(blob).getId();
this is the Folder ID of my account
Well that is where your images are then, someone used my folder this morning
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.