I'm try to upload in image to Firebase storage and then get the download URL from storage in order to save it to my database.
The commented out line works so I know its a problem with the "getDownloadURL" function or either in my storage reference. I have a similar function that works with a shorter reference (userId + '/' + profilePicture).
let returnVal;
const image = 'data:image/jpeg;base64,' + result;
const pictures = firebase.storage().ref(userId + '/' + newPostKey +'/' + 'pictures');
pictures.putString(image, `data_url`);
//firebase.database().ref('Posts/' + userId + '/' + newPostKey).child('photoURL').set("ifni");
firebase.storage().ref(userId + '/' + newPostKey + '/' + pictures).getDownloadURL().then(function (url) {
// Execute (unknown)
returnVal = url;
firebase.database().ref('Posts/' + userId + '/' + newPostKey).child('photoURL').set(returnVal);
})