'Undefined $event when trying to generate a path
To upload a picture into Firebase storage, I am creating a path for the AngularFireStorage.upload method:
In the template, an input to select the file:
<input type="file" class="file-upload" (change)="genPath($event)" accept="*.png.jpg" id="">
In the TS class, a method to generate the path:
path!:string;
genPath(source:any){
this.path = source.path.target;
}
When I don't specify (any): I have the following error message
Parameter 'source' implicitly has an 'any' type.
but when I do then call the upload method, the console has this answer:
uploadImage(){
console.log(this.path);
this.AngularFireStorage.upload("/files"+ Math.random()+ this.path,this.path)
}
Solution 1:[1]
The solution was to change the firebase storage rule:
allow read, write: if false;
to
allow read, write: if request.auth == null;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |