I'm trying to upload to my Storage bucket and then get the downloadURL to that uploaded file right after the upload is done. This was working previously but has since stopped for some reason.
My console print is just returning null. I was hoping for a solution or even a better way of doing this. Any help would be awesome!
I'm using Angular 5.
Here is my current method:
upload(event) {
this.showProgressBar = true;
const randomId = Math.random().toString(36).substring(2);
this.ref = this.afStorage.ref(randomId);
this.uploadTask = this.ref.put(event.target.files[0]);
this.uploadProgress = this.uploadTask.percentageChanges().subscribe(progress => {
console.log(progress);
document.querySelector('#progressBar').style.width = progress + "%";
if(progress === 100){
this.showProgressBar = false;
this.showUploaded = true;
this.downloadURL = this.uploadTask.downloadURL().subscribe(url => {
console.log(url);
});
}
});
}
Here is the way that I coded using angularfire 2 for the file uploading process.
Here is the part of the component I’m using in an Ionic app to upload up to 5 pics
The relevants parts of the code are: