I'm trying to get the URL
of an audio file in Cloud Storage. I can post to the storage just fine, but this function only returns null. When debugging it hops over both onSuccess
and onFailure
.
I know the filename variable is correct, but have tried hardcoding it as well with no success. I'm passing mStorageRef
in as the StorageReference
. fileUrl is currently a global string.
mStorageRef = FirebaseStorage.getInstance().getReference();
String getFileUrl(String filename, StorageReference storageRef) {
storageRef.child("music").child(filename).getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
fileUrl = uri.toString();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
fileUrl = e.getMessage();
}
});
return fileUrl;
}
The files are within a top-level folder called music.