Firebase Storage Bug Trying To Insert Data Into My Database
I have been looking around some questions but can't get to the point of what I'm doing wrong. I'm trying to upload a file to Firebase storage and then write the download URL inside
Solution 1:
The problem is caused by your call to getDownloadUrl()
:
return mStorageReference.getDownloadUrl();
My guess is that mStorageReference
points to the root of your Cloud Storage bucket, so you're asking for the download URL of the entire bucket, which isn't allowed.
To solve this, as for the download URL of the StorageReference
you actually wrote to:
StorageReference fileReference = mStorageReference.child("fotos").child(mAuth.getCurrentUser().getUid()).child(filePath.getLastPathSegment())
fileReference.putFile(filePath).continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
@OverridepublicTask<Uri> then(@NonNullTask<UploadTask.TaskSnapshot> task) throwsException {
if (!task.isSuccessful()) {
throw task.getException();
}
return fileReference.getDownloadUrl();
}
...
Btw: I found this by searching for the "Developer credentials required" from the error message](https://www.google.com/search?q=firebase+storage+"Developer+credentials+required").
Post a Comment for "Firebase Storage Bug Trying To Insert Data Into My Database"