0
我有一個應用程序,可將每個用戶的個人資料圖片存儲在Firebase存儲中。這是我用來存儲個人資料圖片的路徑:使用他們url.But基於uids訪問Firebase存儲圖像
FIRStorage.storage().reference(forURL: "gs://gsignme-15916.appspot.com").child(user.uid+"/profile_pic.jpg")
我也存儲在火力數據庫中的圖像,當我嘗試使用此代碼來訪問個人資料圖片。
if (post["uid"] as? String) != nil {
let imageRef = FIRStorage.storage().reference().child((uid)!+"/profile_pic.jpg")
imageRef.data(withMaxSize: 25 * 1024 * 1024, completion: { (data, error) -> Void in
if error == nil {
let image = UIImage(data: data!)
cell.UserImg.image = image
cell.UserImg.layer.cornerRadius = 10
cell.UserImg.clipsToBounds = true
}else {
print("Error downloading image:")
}})}
而且我改變了用戶,圖片變成了當前用戶的圖片,而不是發了帖子的用戶。我知道問題在於如何檢索圖像,但我不確定如何根據不是當前登錄用戶的uids檢索圖像。
一個空字符串最終是誰取得包含在帖子的人的UID firebase發佈信息? –
如果* uid *是當前用戶的id,那麼假設您已將海報uid存儲爲帖子的一部分,您所要做的就是更改* post [「uid」] * – Russell
@Russell我將userpic更改爲但它仍然顯示當前用戶在所有帖子上的圖片 – juelizabeth