I am trying to get the names and url of the subfolders and files inside a directory in Firebase Storage.
But the listAll is always going to onFailure
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference listRef = storage.getReference();
listRef = listRef.child("Musics");
Log.d("hafiz", listRef.getName());
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.
Log.d("hafiz", prefix.getName());
}
for (StorageReference item : listResult.getItems()) {
// All the items under listRef.
Log.d("hafizitem", item.getName());
}
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// Uh-oh, an error occurred!
//
Log.d("jibon", e.getMessage());
}
});
I tried the following code:
i am getting this error:
An unknown error occurred, please check the HTTP result code and inner exception for server response.
here is my storage rule:
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write;
}
}
}
Recognized by Google Cloud Collective