如何从网页上的Firebase数据库获取图像

时间:2019-08-01 14:37:27

标签: firebase firebase-storage

我是Firebase的新手。我的问题是我试图从Firebase存储器中获取一张图像以显示在名称为addressproofback的网页上,但没有发生。怎么做?

我的整个代码是:-

var database;
    var firebaseConfig = {
    apiKey: "---------------------------------",
    authDomain: "---------------------------------",
    databaseURL: "------------------------------------",
    projectId: "---------------------------------------",
    storageBucket: "---------------------------------------",
    messagingSenderId: "--------------------------------------",
    appId: "--------------------------------------------------"
  };

       firebase.initializeApp(firebaseConfig);

        var storage = firebase.storage();

        var storageRef = storage.ref("Drivers_Documents");


        var tangRef = storageRef.child("+916380104388/addressproofback");


        tangRef.getDownloadURL().then(function(url) 
        {


            var test = url;
           document.getElementById("img1").src = test;
        }).catch(function(error) 
        {
            console.error(error);
        });
<!DOCTYPE html>
<html>
    <head>
        <meta name="description" content="Load image from storage">
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>


<!-- <input type="button" value ="view Image" id="viewbtn" onclick="showimage()"> -->
 <img  height="125px" width="200px" id="img1" src=""/>  

<script src="https://www.gstatic.com/firebasejs/6.3.0/firebase.js"></script>
<script src="https://www.gstatic.com/firebasejs/6.3.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.1.0/firebase-database.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.1.0/firebase-storage.js"></script>


<script src="https://www.gstatic.com/firebasejs/6.3.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/6.3.0/firebase-firestore.js"></script>

</body>
</html>

这就是即将到来的错误

enter image description here

这是安全规则: enter image description here

这是存储空间: Driver_Documents-> + 916380104388-> addressproofback

0 个答案:

没有答案