Using Angular 7, I'm trying to upload an image with Angularfire2
ts
uploadFile(event) {
const file = event.target.files[0];
const filePath = 'name-your-file-path-here';
const ref = this.storage.ref(filePath);
const task = ref.put(file);
}
html
<input type="file" (change)="uploadFile($event)">
Get the following error:
POST https://firebasestorage.googleapis.com/v0/b/my-bucket-name/o?name=name-your-file-path-here 400
{ "error": { "code": 400, "message": "Permission denied. Could not access bucket my-bucket-name. Please enable Firebase Storage for your bucket by visiting the Storage tab in the Firebase Console and ensure that you have sufficient permission to properly provision resources." } }
I have read that I must add in the [email protected]
console as a storage administrator but this did not solve the problem.
My rules in Firebase Storage are:
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write;
}
}
}
Any ideas?