2017-08-17 83 views
0

我正在使用firebase與angular2。我累了訪問圖像的存儲桶的firebase與圖像的直接url。它提供了一些安全錯誤,但在地址欄中輸入相同的圖像可直接在瀏覽器中查看。Angular2Fire在存儲中訪問圖像

<img src="gs://img url in firebase storage"> 

它提供了以下錯誤 enter image description here

然後,我通過以下鏈接Angular2Fire Image access嘗試過的方法。但是它返回的是對象而不是URL訪問。

TS:

recommendedListBind(list){ 
list.forEach(lists => { 
    const storageRef = firebase.storage().ref().child(lists.thumbnail); 
    let thumbnail = storageRef.getDownloadURL().then(url => url); 

    let Detail = { 
     title : lists.title, 
     thumbnail : thumbnail, 
    } 

    this.recommendedList.push(Detail); 
    }); 
}; 

HTML:

<ul> 
    <li *ngFor="let List of recommendedList"> 
    <div class='cards'> 
     <img src={{List.thumbnail}} alt={{List.title}} title={{List.title}} /> 
    </li> 
</ul> 

它提供了以下消息: enter image description here

哪些是火力存儲存取圖像正確的做法?

回答

1

使用Firebase Storage API時,可以實現身份驗證,也可以使用不需要身份驗證的下載url,並且該身份驗證基於可以在控制檯中取消的令牌。

你可以找到更多有關身份驗證的The Google Firebase Storage Security Documentation並在AngularFire2 github上

+0

我不使用驗證,並存儲爲開放閱讀所有 – Prabhakaran

+1

然後,你將不得不使用將downloadURL找到[這裏](HTTP: //imgur.com/a/NO78c) –

+0

如果我撤銷意味着我不能使用圖像知道?將使用下載圖像URL是一個安全威脅,因爲存儲是開放給所有人閱讀? – Prabhakaran