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")
但是应用程序崩溃了,我收到以下消息:
Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: 'Provided bucket:
slugbug-....appspot.com does not match the Storage bucket of the
current instance: (null)'
即使我用
let storageRef = FIRStorage().reference()
桶为零。
为什么?
使用下面的代码工作
// 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
}
})
你错过了.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")
...一个非常微妙但烦人的错误
我有以下代码:
let storageRef = FIRStorage().reference(forURL: "gs://slugbug-....appspot.com") // dots intentional
let imageRef = storageRef.child("testImage.jpg")
但是应用程序崩溃了,我收到以下消息:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Provided bucket: slugbug-....appspot.com does not match the Storage bucket of the current instance: (null)'
即使我用
let storageRef = FIRStorage().reference()
桶为零。
为什么?
使用下面的代码工作
// 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
}
})
你错过了.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")
...一个非常微妙但烦人的错误