새소식

Framework/✨ Google Firebase

How to fix firebase storage is not a function

728x90

🔥 Problem

👉 firebase.storage is not a function

Cause of error

👉 Try using the relative route.

🧙 Solution

👉 Please refer to the code below

<script src="/__/firebase/7.4.0/firebase-auth.js"></script>
<script src="/__/firebase/7.4.0/firebase-storage.js"></script>
<script src="/__/firebase/7.4.0/firebase-firestore.js"></script>
<script src="/__/firebase/init.js"></script>
<script>
 
        function fileUpload(file){
            var metadata = {
                'contentType': file.type
            };
 
            var storageRef = firebase.storage().ref();
            var uploadTask = storageRef.child('images/test').put(file, metadata);
            uploadTask.on('state_changed', function(snapshot) {}, function(error) {
                alert("error!");
            }, function() {
                uploadTask.snapshot.ref.getDownloadURL().then(function(downloadURL) {
                    alert('success!');
                });
            });
        }
 
</script>

 

Did my writing help you?

Please press the Thumb Up button
If you have any questions, please leave them in the comments

💯포스트 후원하기
반응형
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.