Android Question FireBaseStorage download!

mrushdi

Member
Licensed User
Longtime User
i have implemented every setting to use FireBaseStorage as described in its library page, upload files is working well but download files not working, I'm getting the blow error:

(IOException) java.io.IOException: Could not open resulting stream.

any advice?.
 

mrushdi

Member
Licensed User
Longtime User
code is same same your example nothing changed.:(

B4X:
Sub Globals
    Private btnUploadAuth As Button
    Private btnDownloadPublic As Button
    Private btnUploadUser As Button
    Private btnSignIn As Button
    Private lblUser As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
End Sub

Sub Activity_Resume
    If Starter.auth.CurrentUser.IsInitialized Then SignedIn
End Sub

Public Sub SignedIn
    btnSignIn.Enabled = False
    btnUploadAuth.Enabled = True
    btnUploadUser.Enabled = True
    lblUser.Text = $"User: ${Starter.auth.CurrentUser.DisplayName}"$
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub btnSignIn_Click
    Starter.auth.SignInWithGoogle
End Sub

Sub btnUploadUser_Click
    File.WriteString(File.DirInternalCache, "1.txt", "Only I can access this resource.")
    Starter.storage.UploadFile(File.DirInternalCache, "1.txt", $"/user/${Starter.auth.CurrentUser.Uid}/1.txt"$)
End Sub

Sub btnDownloadPublic_Click
    'You need to first upload a file from Firebase console.
    Starter.storage.DownloadFile("/public/somefile", File.DirInternalCache, "out.txt")
End Sub

Sub btnUploadAuth_Click
    File.WriteString(File.DirInternalCache, "1.txt", "Any authenticated user can access this resource.")
    Starter.storage.UploadFile(File.DirInternalCache, "1.txt", $"/auth/1.txt"$)
End Sub

Sub Storage_DownloadCompleted (ServerPath As String, Success As Boolean)
    ToastMessageShow($"DownloadCompleted. Success = ${Success}"$, True)
    If Not(Success) Then Log(LastException)
End Sub

Sub Storage_UploadCompleted (ServerPath As String, Success As Boolean)
    ToastMessageShow($"UploadCompleted. Success = ${Success}"$, True)
    If Not(Success) Then Log(LastException)
End Sub
 
Upvote 0

mrushdi

Member
Licensed User
Longtime User
Have you upload the file with Firebase console?
yes i did

the below error is part from the unfiltered error may help in finding a solution:

java.io.IOException: Could not open resulting stream.
at com.google.firebase.storage.StreamDownloadTask.zzadq(Unknown Source)
at com.google.firebase.storage.StreamDownloadTask.zza(Unknown Source)
at com.google.firebase.storage.StreamDownloadTask$1.zzads(Unknown Source)
at com.google.firebase.storage.StreamDownloadTask$1.call(Unknown Source)
at com.google.firebase.storage.StreamDownloadTask$zza.zzadu(Unknown Source)
at com.google.firebase.storage.StreamDownloadTask$zza.read(Unknown Source)
at java.io.BufferedInputStream.read(BufferedInputStream.java:290)
at java.io.InputStream.read(InputStream.java:162)
at anywheresoftware.b4a.objects.streams.File.Copy2(File.java:356)
at anywheresoftware.b4x.objects.FirebaseStorageWrapper$3.doInBackground(FirebaseStorageWrapper.java:112)
at com.google.firebase.storage.StreamDownloadTask.run(Unknown Source)
at com.google.firebase.storage.StorageTask$8.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
StorageException has occurred.
Object does not exist at location.
Code: -13010 HttpResult: 404
Could not open resulting stream.
java.io.IOException: Could not open resulting stream.
at com.google.firebase.storage.StreamDownloadTask.zzadq(Unknown Source)
at com.google.firebase.storage.StreamDownloadTask.zza(Unknown Source)
at com.google.firebase.storage.StreamDownloadTask$1.zzads(Unknown Source)
at com.google.firebase.storage.StreamDownloadTask$1.call(Unknown Source)
at com.google.firebase.storage.StreamDownloadTask$zza.zzadu(Unknown Source)
at com.google.firebase.storage.StreamDownloadTask$zza.read(Unknown Source)
at java.io.BufferedInputStream.read(BufferedInputStream.java:290)
at java.io.InputStream.read(InputStream.java:162)
at anywheresoftware.b4a.objects.streams.File.Copy2(File.java:356)
at anywheresoftware.b4x.objects.FirebaseStorageWrapper$3.doInBackground(FirebaseStorageWrapper.java:112)
at com.google.firebase.storage.StreamDownloadTask.run(Unknown Source)
at com.google.firebase.storage.StorageTask$8.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
StorageException has occurred.
Object does not exist at location.
Code: -13010 HttpResult: 404
Could not open resulting stream.
java.io.IOException: Could not open resulting stream.
at com.google.firebase.storage.StreamDownloadTask.zzadq(Unknown Source)
at com.google.firebase.storage.StreamDownloadTask.zza(Unknown Source)
at com.google.firebase.storage.StreamDownloadTask$1.zzads(Unknown Source)
at com.google.firebase.storage.StreamDownloadTask$1.call(Unknown Source)
at com.google.firebase.storage.StreamDownloadTask$zza.zzadu(Unknown Source)
at com.google.firebase.storage.StreamDownloadTask$zza.read(Unknown Source)
at java.io.BufferedInputStream.read(BufferedInputStream.java:290)
at java.io.InputStream.read(InputStream.java:162)
at anywheresoftware.b4a.objects.streams.File.Copy2(File.java:356)
at anywheresoftware.b4x.objects.FirebaseStorageWrapper$3.doInBackground(FirebaseStorageWrapper.java:112)
at com.google.firebase.storage.StreamDownloadTask.run(Unknown Source)
at com.google.firebase.storage.StorageTask$8.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
query(), uri = 15 selection = getToastGravityEnabledState
query(), uri = 15 selection = getToastGravity
query(), uri = 15 selection = getToastGravityXOffset
query(), uri = 15 selection = getToastGravityYOffset
query(), uri = 15 selection = getToastEnabledState
query(), uri = 15 selection = getToastShowPackageNameState
(IOException) java.io.IOException: Could not open resulting stream.
#1 mView = android.widget.LinearLayout{4cf8fe3 V.E...... ......I. 0,0-0,0 #10203b0 android:id/toast_layout_root}
InputChannelName : 51d47cb Toast
handelAlertToastWindowStarted pkgName = {intentionally removed by me (mrushdi)}
id=5209 createSurf (1x1),1 flag=4, Uoast
[api] acquire WakeLock flags=0x2000000a tag=WindowManager uid=1000 pid=4396
new_window_surface returns 0x3000, [1173x201]-format:1
MSG_RESIZED_REPORT: ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
Finishing drawing window Window{51d47cb u0 d0 Toast}: mDrawState=DRAW_PENDING
eglInitialize EGLDisplay = 0xbec7940c
 
Last edited:
Upvote 0

mrushdi

Member
Licensed User
Longtime User
(Solved) thank you @Erel very much , your question caught my eye to the file name as i left everything in your example untouched but now i recognized that i have to write down the file name after the bucket name.:D
 
Upvote 0
Top