Question about Uploading Files to Firebase Storage

I apologize for my poor English; I'm having to translate this from Portuguese to English. My question is as follows: I'm trying to use Firebase Storage to store PDF documents for a project of my company. I used Kodular and had only managed to send images there. Since Kodular is facing some issues regarding the generation of APK and AAB files, I migrated to MIT App Inventor. So, following some tutorials here, I managed to do some things. However, I'm not able to send my PDF files to Storage. Here is the tutorial I'm following:

So, I noticed that App Inventor doesn't have a component to specifically pick files, so I used the FilePicker extension for that. Then I tried to mix things, but I still get Error 1104. I tried adding 'file://' as well, but no success. I would appreciate some help with this issue, please. Here are my blocks:

Message Error:

See the file path.
It should be file:///storage/emulated/0/....
Triples slash after file:.

However, Firebase Storage extension is available too.

1 Like

Or you can just leave off the file://, as in my example blocks (use a replaceAll text block for this) - however, according to my note below the blocks, this may be generating an error 1104 anyway.

and remove the FirebaseStorage1.mimetype block, because you are declaring the mimetype in the header blocks already.

I'm following along here, but it's not sending to Firebase, and also, at every moment, it seems like the Firebase component is not in my code.

In this way, I was able to get past error 1104, but it's not sending PDFs. Could it be an incompatibility with the FilePicker I'm using?

Did you try in apk or companion?

Oh, I didn't know it was the same as Kodular, that I had to download the APK for it to work, and thank goodness, it worked. Thank you very much! But could you tell me why sometimes it shows 'permission was not granted'? Like, it appears, and then I have to insist 2 or 3 times, and then it goes normally.

You can remove AskForPermission blocks.

Post a screenshot of this message.

The error in question is the one below. To access it, I need to go to the page where I send the file, go back to the previous one, and then go to the file upload page again, and that's how I can work on that page.

With my blocks in this way, I can send the files, but this error gives me a bit of a headache. I don't know how to solve it. I tried removing the read and write permissions, but without them, I can't access the media on the phone.

Hmm... (which Android version you are testing on?)

  1. There is no READ_EXTERNAL_STORAGE on Android 13+.
  2. There is no WRITE_EXTERNAL_STORAGE on Android 11+.
  3. Storage permissions are no longer required for the ASD since API 19 (Android 4.4, KitKat).
  4. WRITE permission is not needed at all.

Therefore, remove storage permissions and request only READ permission on Android < 4.4 (< API 19). If READ permission is required for the ASD on Android ≥ 4.4 (API 19) there is a bug. But I think you get the permission message because of requesting WRITE permission.

If using the web component method, you can use companion or a compiled app.

Using the extension, I managed to send .jpeg and .pdf files, which is wonderful. However, I came across 1 problem. I can only send a single .pdf file of 67,921 bytes. I've tried other files, both larger and smaller, renamed the file, but it only accepts this specific one. Is there something wrong with my blocks that's causing this to happen?

A brief explanation of what I'm trying to do: there will be 5 spaces where the user will fill in with 5 different PDFs. They will fill in the CPF field, which will create a folder in Firebase, and from there, the 5 different files will be saved. But I'm only able to send a single specific one. Do you have any idea what it might be?

If you notice, I even tried changing the 'fileName' at the end to see if it was that, but even when I set it to be a PDF or leave the global variable already defined, it doesn't change. It only accepts this specific PDF, and I tried using the 'uploadFailed' command, but nothing appeared. It just says 'OK' if it's this specific PDF

This works in companion (Android 13)

Uses the native FilePicker, from the Media Palette

but for a compiled app the content uri does not return the file name, so you have to enter it

I followed your example and had this error, man, this is giving me a lot of headaches, and I imagine it's something very simple.

Code:

Error:

Is your storageAppID in the format:

examplename.appspot.com

and ProjectBucket a top line folder name

?

and where/which shared storage directory, are you picking your file from?

Maybe Firebase doesn't like spaces in file name.
Pm me the aia file.


I don't think that is possible. You cannot read / access non-media files on Android 11+, that are not created by the app itself. So it seems that you are picking PDF files, that are created with the Companion app. Copy a new PDF file in one of the Shared folders and try again.

Downloaded a pdf from my gmail to the Downloads folder, so not created by companion or any other app.

Worked with companion and the compiled app, but had to supply a file name for both.

Hmm, I also checked it on Android 9 and 13. Works fine with READ permission on Android 9 but does NOT work (as expected) on Android 13 (11+).