upload and download images to cloud

1,157 views
Skip to first unread message

Marco29

unread,
Jun 10, 2018, 7:23:05 AM6/10/18
to MIT App Inventor Forum
How can I upload images to cloud through app inventor?
I would like to build an app that manages user profiles' images.
The user chooses an image for his own profile and all the other users will be able to see the chosen image. how about what's up! or other similar applications.
How can I use mit app inventor for this purpose?



SteveJG

unread,
Jun 10, 2018, 7:48:24 AM6/10/18
to MIT App Inventor Forum
Unlike the FirebaseDB control and other App Inventor controls, the CloudDB control allows uploading images directly to the database.  You can store and retrieve small images using the CloudDB.

Also, you can store images in your GoogleDrive, enable share and allow users to access the images there  as described by Tim



Is this what you wanted to know?

Regards,
Steve

Marco29

unread,
Jun 10, 2018, 2:12:56 PM6/10/18
to MIT App Inventor Forum
Thanks SteveJG, this evening I work about it and I'll tell you!
thanks 

Marco29

unread,
Jun 10, 2018, 2:28:46 PM6/10/18
to MIT App Inventor Forum
Could you tell me any examples, tutorial about image and CloudDB ?
thanks
Marco
 

SteveJG

unread,
Jun 10, 2018, 3:32:25 PM6/10/18
to MIT App Inventor Forum
The CloudDB works almost exactly like a FirebaseDB control.   Search for tutorials about Firebase and App Inventor.

A huge difference is a CloudDB can accept small png images and probably larger images as long as they are not too big.  The following is a very simple example of how to work with a CloudDB and images.

The example uses two Buttons, an Image control and the CloudDB control (the three Cloud component blocks shown). Put an image into your Media (you have to have an image to send to the database).  First send the down.png to a CloudDB tag using Button1. then retrieve the image using Button2 and the GotValue block.   

Try the simple example first.

Now you are ready for a more complex example



Does this work for you Marco?

Regards,
Steve


down.png

Marco29

unread,
Jun 10, 2018, 4:37:54 PM6/10/18
to MIT App Inventor Forum
thanks, you have been very kind.
I'll try to use this example
I'll tell you about

Marco29

unread,
Jun 10, 2018, 5:05:06 PM6/10/18
to MIT App Inventor Forum
hello Steve I tried to use CloudDB successfully!!!
I have another question about.
Are there any limits about use cloudDB?
For example to save images, one for each user of my app ...
How many images, how many byte I can save in cloudDB?

SteveJG

unread,
Jun 10, 2018, 6:08:39 PM6/10/18
to MIT App Inventor Forum
There are limits certainly.  The default MIT Redis server CloudDB is not intended for commercial apps.  

The documentation for the CloudDB is here  http://ai2.appinventor.mit.edu/reference/components/experimental.html  .

If you expect many users,  establish a Redis server of your own rather than using the default MIT Redis server.  

Marco29

unread,
Jun 11, 2018, 2:43:23 AM6/11/18
to MIT App Inventor Forum
thanks Steve for the precious information.
Best Regards
Marco

Abraham Getzler

unread,
Jun 11, 2018, 4:39:00 PM6/11/18
to MIT App Inventor Forum
Something's fishy here.

I haven't tried image storage on Firebase yet.
How can it tell the difference between the text value "image.png"
versus the actual image file image.png at upload time?

Are those image files made visible only on the phone already containing
the image.png file, or are other app users without the image
file suddenly able to display it on download?

ABG

Message has been deleted

Taifun

unread,
Jun 11, 2018, 5:23:36 PM6/11/18
to MIT App Inventor Forum

Abraham Getzler

unread,
Jun 11, 2018, 8:34:08 PM6/11/18
to MIT App Inventor Forum
I thought of a counter-experiment to disprove the theory
that the CloudDB blocks will upload an image file
(not the file name, but the actual file.)

Add an Image component to the PaintPot app,
same size as the Canvas.

Add buttons to ...

Draw a masterpiece on the Canvas.
save the Canvas as a file.
Set the Image to the saved file name.
Observe the Image, does it look like the Canvas?
Remember what you drew.
Upload the saved file to CloudDB (no Web stunts), tag = 'image'
Clear the Canvas.
save the Canvas as a file, same file name as before, to trash it.
Request tag 'image' from CloudDB.
When tag 'image arrives, set Image component to the saved file name.

The critical test:  Has the masterpiece been restored?

(I will start coding this.)
ABG


Abraham Getzler

unread,
Jun 11, 2018, 9:13:20 PM6/11/18
to MIT App Inventor Forum
I've attached the sample app.

There is no sign of image files being uploaded or downloaded by AI2 CloudDb blocks,
just text file names.

ABG



Capture.PNG
cloudDB_images.aia
Designer.PNG
blocks.png
Message has been deleted

Abraham Getzler

unread,
Jun 12, 2018, 12:17:42 AM6/12/18
to MIT App Inventor Forum
Your cloudimage.aia posts the text URL to CloudDB, and retrieves that same text URL.

The Image component loads the image file from the web when given a URL.

That is quite different from saving a file to CloudDB.

ABG

SteveJG

unread,
Jun 12, 2018, 10:01:47 AM6/12/18
to MIT App Inventor Forum
...also  I got the direct link to the captured image to display          Image1.Picture =       file:///mnt/sdcard/ABG_test.png   works so contrary to previous comments; the captured Canvasa does display in a Image component.

SteveJG

unread,
Jun 12, 2018, 10:51:17 AM6/12/18
to mitappinv...@googlegroups.com
Abraham's experiment appears to demonstrate that the CloudDB is not saving images.

When the Image control is used in Companion, the appearence of "saving" the image into the CloudDB is there, possibly because of the way either Companion or the Image control 'works.' When compiled, it is apparent the saving of the actual file does not happen.

I tested the behavior of the CloudDB control several months ago.  It appeared the CloudDB on the MIT Redis server was in fact actually saving the images on the server (not just the image 'name').   I do not know whether MIT changed the behavior of the CloudDB since then.

At the moment, the CloudDB tool is NOT saving image files, only their names. Sorry for any confusion my post has generated.

Abraham Getzler

unread,
Jun 12, 2018, 11:12:23 AM6/12/18
to MIT App Inventor Forum
If I may recap, 

 FireBaseDB has a file upload capability through a stunt with the Web component' post block and laboriously built html (Thanks Taifun)
 FIreBaseDB and CloudDB can upload and download Base64 text translations of an image file, but you need an extension (Thanks Taifun)
 Neither has direct block support for files, which would be nice to have.
 
ABG
Reply all
Reply to author
Forward
0 new messages