Android Question Firebase Storage File List

trepdas

Active Member
Licensed User
Longtime User
Hi,
I was wondering if there's any update on this.
Can one list files in firebase storage, 5 years later?
 
Upvote 0

trepdas

Active Member
Licensed User
Longtime User
here's the Java code from that page...

B4X:
  public void listAllFiles() {
        FirebaseStorage storage = FirebaseStorage.getInstance();
        // [START storage_list_all]
        StorageReference listRef = storage.getReference().child("files/uid");

        listRef.listAll()
                .addOnSuccessListener(new OnSuccessListener<ListResult>() {
                    @Override
                    public void onSuccess(ListResult listResult) {
                        for (StorageReference prefix : listResult.getPrefixes()) {
                            // All the prefixes under listRef.
                            // You may call listAll() recursively on them.
                        }

                        for (StorageReference item : listResult.getItems()) {
                            // All the items under listRef.
                        }
                    }
                })
                .addOnFailureListener(new OnFailureListener() {
                    @Override
                    public void onFailure(@NonNull Exception e) {
                        // Uh-oh, an error occurred!
                    }
                });
        // [END storage_list_all]
    }

now, how we make it b4x alike?
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
here's the Java code from that page...

B4X:
  public void listAllFiles() {
        FirebaseStorage storage = FirebaseStorage.getInstance();
        // [START storage_list_all]
        StorageReference listRef = storage.getReference().child("files/uid");

        listRef.listAll()
                .addOnSuccessListener(new OnSuccessListener<ListResult>() {
                    @Override
                    public void onSuccess(ListResult listResult) {
                        for (StorageReference prefix : listResult.getPrefixes()) {
                            // All the prefixes under listRef.
                            // You may call listAll() recursively on them.
                        }

                        for (StorageReference item : listResult.getItems()) {
                            // All the items under listRef.
                        }
                    }
                })
                .addOnFailureListener(new OnFailureListener() {
                    @Override
                    public void onFailure(@NonNull Exception e) {
                        // Uh-oh, an error occurred!
                    }
                });
        // [END storage_list_all]
    }

now, how we make it b4x alike?
Well if it's not implemented in a B4A library I guess you could try inline Java - but it's not really my thing, so I couldn't tell you how. :)

- Colin.
 
Upvote 0

trepdas

Active Member
Licensed User
Longtime User
As of May 2019, version 6.1.0 of the Firebase SDK for Cloud Storage now supports listing all objects from a bucket. You simply need to call listAll() in a Reference:

I guess that the firebase storage lib needs an update to make this work :

B4X:
Dim storage As FirebaseStorage = CreateFirebaseStorage
Dim PubList() as list = storage.ListAll("/public/")


Sub CreateFirebaseStorage As FirebaseStorage
    Dim storage As FirebaseStorage
    storage.Initialize("storage", bucket)
    Return storage
End Sub


How do I #if java this ?
 
Last edited:
Upvote 0
Top