How can I inform a user that his file has been uploaded successfully to firebase?


I'm currently using the web component on MIT App Inventor to upload a file to firebase storage.

In cases where the file is large in size, it takes a certain amount of time for the user's file to upload to firebase. I want to let the user know that his file has been uploaded when it finishes uploading- maybe update a label to say "Uploaded" or change the color of a label to green.

Is there a way I can determine whether a file in a particular firebase path has been changed/updated? I was thinking it would involve the metadata of the file on firebase- since the metadata contains the time of upload.

I didn't find any concrete solutions online- any help on this topic is appreciated. Maybe an extension or web component block that can make this work.

When a user uploads a file to firebase storage using the web component, quite a lot of data about the upload is returned, on completion:

Upload a File

When a user uploads a file to firebase storage using the web component, quite a lot of data about the upload is returned, on completion

Sorry if this is a silly question, but where does this data get returned? How do we access it?

In your example, you received:

[["bucket", ""], ["contentDisposition", "inline; filename=utf-8''myimage1.png"], ["contentEncoding", "identity"], ["contentType", "image/png"], ["crc32c", "AlvaFg=="],* ["downloadTokens", "69c52b42-32d1-40a0-9b98-574872eeed2c"], ["etag", "CO+Dx4SB1ewCEAE="], ["generation", "1603809785790959"], ["md5Hash", "ZGOY4M+44ZmWCTAHLvtCtQ=="], ["metageneration", "1"], ["name", "FBDEMONOSEC/myimage1.png"], ["size", "38106"], ["storageClass", "STANDARD"], ["timeCreated", "2020-10-27T14:43:05.790Z"], ["updated", "2020-10-27T14:43:05.790Z"]]

Where can I see this in my project?

Web1.GotText - responseContent

The format may be in json now, and therefore need converting to a dictionary to access individual elements

Is this enough to save the response to a tag named "ReturnedData" in my database?
Can I use the DataChanged block to know when the tag value changes? When it does, I can tell the user that the file has been uploaded.


Probably not, because if another file is uploaded then it will overwrite the existing data of the previous file, which will be needed in order to view/download the file in the future....

If the user is uploading the file, then they will know this because they will get the confirmation that the file is uploaded. Is someone else somewhere else changing the uploaded file ?

Do you need to inform all users that a file has been uploaded, regardless of who uploaded it ?

It's okay for me if the data of the previous file gets overwritten :slightly_smiling_face:

Only one user will be using the application, it is enough if only the person uploading the file knows that the file has been changed.

Why is the file changing, and who is changing it?

In my application, the user uploads a text file to firebase.
This file is then called by an ESP8266, which is then sent to a microcontroller unit to rewrite its firmware.
The textfile is the firmware of the microcontroller. The file will be changed when the user wants to rewrite the firmware of the microcontroller. He will upload a file maybe once a month when he wants to update the firmware remotely.
The previous file, is hence, not important to him- he already has it.

Is there any documentation on how to use the DataChanged block?

Does the block get triggered when there's any change on the database or can we set it so it gets triggered when only a tag's data gets changed?

I don't understand why you need dataChanged ?

If there is only one user, and they are uploading the file to firebase storage, then they will know that they have done this, and will get a return after the upload confirming this.

To answer your question, the dataChanged event block provides for a tag to be tested and for the value of that tag to be captured/displayed. The only quirk with the dataChanged event is that the client (device) must initiate contact with Firebase, perhaps by sending a request or posting s dummy value, in order to get the dataChanged process running.

1 Like