Upload Image to Google Drive using base64 TimAI2 using Camera Image

2308 views
Skip to first unread message

Jacob

unread,
Apr 23, 2018, 11:09:52 AM4/23/18
to mitappinv...@googlegroups.com
TimAI2, the app has so far worked fine, but when I attempted to add a camera function I get the error "Attempt to invoke virtual method "boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat, int,java.io.OutputStream)' on a null object reference". I assume it is attempting to compress the image, but is unable to do so. I am hoping there is some sort of blatant error that has an easy fix. I know the imagepicker1 works perfectly, and I have uploaded multiple photos to my google drive without issue. 
Image4.png

Jacob

unread,
Apr 23, 2018, 11:22:13 AM4/23/18
to MIT App Inventor Forum
@TimAI2

TimAI2

unread,
Apr 23, 2018, 11:26:50 AM4/23/18
to MIT App Inventor Forum
This is what comes back (for me) when taking a picture with the camera and when using the image picker to return the same image just taken


so it may be simply just a matter of editing the file path ?


Other things to try - skip the tinydb and just put the "image" straight to the encoder

 

Jacob

unread,
Apr 23, 2018, 12:08:16 PM4/23/18
to MIT App Inventor Forum
When I skipped the tinydb and used get image I got the same error as before. If I use the imagepicker to upload a picture and then use the camera function and choose upload (ignoring the error that is displayed) then it uploads the image a second time that I chose with image picker ignoring that I used the camera function.

TimAI2

unread,
Apr 23, 2018, 1:37:24 PM4/23/18
to mitappinv...@googlegroups.com
Using my original example as a base


I added a camera component and a button, then added these blocks


This works, and successfully uploaded the photo from the camera.


The trick was to shorten the url being provided by the camera "image" by removing: "file://"


In your case I suggest you do this bit first then do your tinydb stuff



Thanks for the creativity, it is a useful addition to my original idea :)

Jacob

unread,
Apr 25, 2018, 9:51:56 AM4/25/18
to MIT App Inventor Forum
That worked! Thank you for finding a way to make the camera work. My plan for the app is to use it to take pictures of words or papers and upload the .jpg file and open it with google docs which automatically converts the text in the picture into a google doc that can be edited. 

Taifun

unread,
Oct 12, 2018, 2:23:07 PM10/12/18
to MIT App Inventor Forum
reopened

Meghraj Singh

unread,
Oct 12, 2018, 2:24:18 PM10/12/18
to MIT App Inventor Forum
Hi Tim,
I was following your tutorial and have done the things exactly same.
  1. Create Folder in my Google Drive (Noted the id from URL)
  2. Create a new Google Script project and published it on web, being me and giving access to everybody.
  3. Provided the web app url in app inventor application
  4. corrected the folder id.

Within application i got notifier, “Upload Successful” but nothing came to my folder. Is there any other ground work i need to do before all this. May be creating console project then client id and credentials something like that??

TimAI2

unread,
Oct 12, 2018, 3:07:19 PM10/12/18
to MIT App Inventor Forum
Reply all
Reply to author
Forward
0 new messages