簡體   English   中英

Firebase:提供的存儲桶與Swift中當前實例的存儲存儲桶不匹配

[英]Firebase: Provided bucket does not match the Storage bucket of the current instance in Swift

我有以下代碼:

let storageRef = FIRStorage().reference(forURL: "gs://slugbug-....appspot.com") // dots intentional
let imageRef = storageRef.child("testImage.jpg")

但應用程序崩潰,我收到以下消息:

由於未捕獲的異常'NSInvalidArgumentException'而終止應用程序,原因:'提供的存儲桶:slugbug -.... appspot.com與當前實例的存儲桶不匹配:(null)'

即使我使用

let storageRef = FIRStorage().reference()

桶是零。

為什么?

你缺少.storage()

檢查你的線路。 它應該是:

let storageRef = FIRStorage.storage().reference(forURL: "gs://slugbug-....appspot.com") // dots intentional

希望能幫助到你

我想出了解決方案:

我更改了代碼:

let storageRef = FIRStorage().reference(forURL: "gs://slugbug-....appspot.com")

至:

let storageRef = FIRStorage.storage().reference(forURL: "gs://slugbug-....appspot.com")

......一個非常微妙但煩人的錯誤

使用下面的代碼工作

 // call storage ref from link
 self.storageRef =  FIRStorage.storage().reference(forURL: "your_URL")

     // Assuming your image size < 10MB.
     self.storageRef.data(withMaxSize: 10*1024*1024, completion: { (data, error) in
           if data != nil{ // if image found 
              let photo = UIImage(data: data!)
                  // User photo here
               }
     })

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM