Android Question Firebase storage issue

iCAB

Well-Known Member
Licensed User
Longtime User
Hi All

I am getting this error: (IOException) java.io.IOException: Could not open resulting stream.
with the Firebase storage sample project provided in the link below:
https://www.b4x.com/android/forum/threads/firebasestorage-simple-file-storage-backend.68350/#content
Authentication is also failing.

Here is what I have done:
1. downloaded sample project
2. changed package name
3. downloaded the JSON file and placed it in the project folder
4. changed the bucket name in the source code to match the project
5. copied the rules from the first post in the above link and applied to the project (bucket name also changed inside the rules). I even attempted to make everything public, but still facing the issue
6. created a subfolder "somefile" under public and copied "out.txt" file to the subfolder
7. Download code looks like this
B4X:
Sub btnDownloadPublic_Click
    'You need to first upload a file from Firebase console.
    Starter.storage.DownloadFile("/public/somefile/out.txt", File.DirInternalCache, "out.txt")
End Sub

I am getting this error as a result of executing the above code
(IOException) java.io.IOException: Could not open resulting stream.


any ideas what could be causing the issue.

Thanks in advance
 
Last edited:

iCAB

Well-Known Member
Licensed User
Longtime User
Can you post your Firebase rules?
Hi Erel, please see below

B4X:
service firebase.storage {
  match /b/xxxxxx.appspot.com/o {
  match /auth/{allPaths=**} {
     allow read, write: if request.auth != null;
   }
  match /public/{allPaths=**} {
  allow read;
  }
  match /user/{userId}/{allPaths=**} {
  allow read, write: if request.auth.uid == userId;
  }

  }
}
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
Erel, please don't spend time on it. I think the problem is actually related to the Firebase console.

Here is some background:
  • Rules Tab was causing issue. Every time I clicked it, I was getting this error "Error loading rules: Requested entity was not found"
  • I downloaded and used the CLI command line utility to create the rules
  • The rules became visible in the project window and Rules Tab became accessible
  • I deployed the rules
  • I think something still not working properly on their end

Step 2
  • I created a new firebase project
  • Rules Tab was accessible (as you would expect)
  • Applied the exact same rules & setup as in the project with issues
  • Everything works fine (meaning I can upload/download no issues)
I just opened a ticket with Firebase and waiting for a reply

Thanks for your efforts
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
Yes, it shows the same !!
Hi Tareq, what shows the same? Can you please clarify.
Are you getting the error in the Firebase console or "(IOException) java.io.IOException: Could not open resulting stream"

One thing, I can tell you is this:
After I determined that my code didn't have an issue (using a secondary test project as mentioned above), I opened a case with Firebase Tech support for the existing project. Even though I was told they were not able to find an issue, somehow the problem disappeared mysteriously while they were testing my storage bucket permissions :)
 
Upvote 0
Top