I cannot upload multiple images to the same firebase tag and get a random one back

Hello Friends,

I am fairly new to App Inventor and I need a bit of help.

I have a project for Uni. The idea is that there are different locations scattered all around the city. These locations have a tag. Now different people can go to these locations, and my typing the location id they can upload a picture of how the location looks. After uploading a picture that isn't theirs gets shown. So for example person 1 goes and takes a picture at location x and then afterwards person 2 also takes a picture at location x but the picture that they get shown is the picture of person 1. I hope I’m explaining it in an understandable way.

Now I have the whole uploading with the tag and getting the image part of the app down and it works. The problem is that the pictures get overwritten when a new picture gets uploaded with the same tag. I tried doing it with the clock (every picture gets the location tag and the milliseconds as a tag) but I can't figure out how to get a random picture from that same location tag.

as you can see I have converted the image to base64 and uploaded it and the same image gets shows when you tag on show image but that’s not the point of the app.

It would be great if anyone has any clue how to make it so:

  • a random image from the same tag gets shown
  • the uploaded images don’t get overwritten

You could do something like this, using the web component:

image
( I used just text for the data, you would use a base64 string of the image, then handle this on return)

1 Like

Thanks so much for the response!!

Is there a possibility to do that with firebase?

For extra info:

it is important to my professor that we use firebase. So if you guys have any solutions that work with firebase that would super super great!!

My example is using Firebase as a data store. It does not use the ai2 firebase component.

1 Like

oh alright!

could you maybe also explain what the "FBDEMONOSEC/" means does that have anything to do with the firebase or can I use the same one too

Okay so I just tried it now with the code that you sent me and I get this error

Here's the code and the design


Troubleshooting is pretty hard seeing as I don’t know what most of the web stuff means this is the first time I’m seeing it used

This

is not your firebase project url

should be of the form:

https://<projectname>.firebaseio.com/

another example:

https://myproject-3c620-default-rtdb.firebaseio.com/

You also need to set the responseContent, for getVar=2, to be converted to an image file, trying to set the base64 string to a label may crash the app

1 Like

Hey!

How do I set the responseContent for getVar=2 that you said?

Also is there a possibility that you could explain what you are doing here a tiny bit so I understand what I’m coding.

Thank you for being so helpful!

Okay so I did this. It uploads the pictures but it doesn't get them idk what I’m doing wrong :frowning:

Please Help!! My exam is in 2 days

image

1 Like

it still doesn't seem to work it shows me the same picture that was uploaded or it says bad base

I get "Runtime Error, bad base-64"

here is the current code

you use the Base64ToImage at wrong place.
You need to place it after you get the base64. This does not mean after 'web.get' block, but after 'web.gotText'.

1 Like

Try like this:

image

1 Like

Okay I tried it and again it doesn't show a picture when I tap on get image it doesn't do anything

here's the code and the design


->when you open the screen


->after uploading the picture


Okay it works now but it I can only tap two times and only see two pictures before the second button doesn't work anymore

Turns out it was just a bug the app works!!! Thank you to the ones who helped you saved my semester!!!! <3

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