Android Question Firebase Storage - get list of file names into a b4xTable [solved]

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Add to Firebase rules tab, at the top:
B4X:
rules_version = '2';
2.
B4X:
Sub ListAll(ServerPath As String) As ResumableSub
    Dim fs As JavaObject = Starter.storage
    fs = fs.GetField("fs")
    Dim res As List
    Dim ref As JavaObject = fs.RunMethod("getReferenceFromUrl", Array(Starter.bucket & ServerPath))
    Dim task As JavaObject = ref.RunMethod("listAll", Null)
    Do While task.RunMethod("isComplete", Null) = False
        Sleep(100)
    Loop
    If task.RunMethod("isSuccessful", Null) Then
        Dim ListResult As JavaObject = task.RunMethod("getResult", Null)
        Dim Items As List = ListResult.RunMethod("getItems", Null)
        res.Initialize
        For Each ref2 As JavaObject In Items
            res.Add(ref2.RunMethod("getPath", Null))
        Next
    Else
        Log("Error")
        Log(task.RunMethod("getException", Null))
    End If
    Return res
End Sub

3.
B4X:
Wait For (ListAll("/public")) Complete (Paths As List)

Check the unfiltered logs if there is any error.
 
Upvote 0

trepdas

Active Member
Licensed User
Longtime User
COOL !!!!
Worked like a charm !

Thank you Erel !!
scfb.jpg
 
Upvote 0

asales

Expert
Licensed User
Longtime User
B4X:
Wait For (ListAll("/public")) Complete (Paths As List)

Check the unfiltered logs if there is any error.

I can list the files from the paths: "/public" and "/auth", but not from "/user".

There is no error in the unfiltered logs

Any tip to list the files from "/user"?

Thanks in advance.
 
Upvote 0
Top