I want to upload file in my Firebase Storage and I want to get the percent uploaded and at the end, the download URL.
I've try everything that I can but I have :
TypeError: Cannot read property 'then' of undefined
This is my function :
$scope.createCatalog = function(catalog,uid,setColor,setBg){
console.log(catalog);
StorageService.put(catalogs,uid,medias,catalog.logo).then(function(success){
console.log(success);
})
}
This is my code in my service :
put : function(name,userID,item,data){
var itemRef = firebase.storage().ref().child("users").child(userID).child(name).child(item);
var itemFile = $firebaseStorage(itemRef);
var uploadTask = itemFile.$put(data);
uploadTask.$progress(function(snapshot) {
var percentUploaded = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
return percentUploaded
});
uploadTask.$complete(function(snapshot) {
return snapshot.downloadURL
});
}
Thank you all !