Я получаю следующую ошибку при попытке delete()
образа из Firebase Storage:
com.google.firebase.storage.StorageException: User does not have permission to access this object.
Мои правила выглядят так:
service firebase.storage {
match /b/{bucket}/o {
match /users/{userId}/{filename} {
allow read: if request.auth.uid != null;
allow write: if request.auth.uid != null;
}
}
}
И мое дерево ссылок на хранилищевыглядит так:
users > {uid} > {filename}
А вот и вызов функции:
private fun deleteImages(firebaseUser: FirebaseUser){
val firebaseUser = FirebaseAuth.getInstance().currentUser ?: return false
/** Delete user image from storage */
val bucket = "http://myapp.appspot.com.storage.googleapis.com/"
val filename = "Lx0NkP2iTzLnlFupvRq"
Log.d(TAG, "$bucket/users/${firebaseUser.uid}/$filename")
// successfully prints filename url: http://myapp.appspot.com.storage.googleapis.com/users/QX2Qi49j3URbK5FtmWvQT1jWHcw2/Lx0NkP2iTzLnlFupvRq
bucket.child(bucket + "users/${firebaseUser.uid}/$filename").delete().addOnSuccessListener { Log.d(TAG, "First image deleted") }.addOnFailureListener { exception -> Log.d(TAG, "Failed to delete images: $exception") }
}
Есть идеи, в чем проблема?