dimanche 5 juillet 2020

How can I get the downloadURL in poster_book to save to the database

This is my code, I want to get the download URL in the poster_book key to save it in the database.

I need urgent help for this problem


$("#send_poster").on('click', function () {

        var user = firebase.auth().currentUser;
        var displayName = user.displayName;
        var photoURL = user.photoURL;
        var pname = $("#poster-name").val();
        var pauthor = $("#poster-author").val();
        var pdescription = $("#poster-description").val();
        
        var metadata = {
        contentType: 'image',
        };
        
        var uploadBook = document.getElementById("file-upload-book").files[0];
        var uploadTask = firebase.storage().ref('posters/' + uploadBook.name).put(uploadBook, metadata);
        
        firebase.database().ref('posters/' + Date.now()).set({
            poster_name: pname,
            poster_author: pauthor,
            poster_description: pdescription,
            poster_username: displayName,
            poster_book: // get downloadURL here

        });
        
        $("#poster-name").val("");
        $("#poster-author").val("");
        $("#poster-description").val("");
        $("#file-upload-book").val("");
    });



Aucun commentaire:

Enregistrer un commentaire