Firebase: provided bucket is not the same as the storage bucket of the current instance in Swift
I have the following code:
let storageRef = FIRStorage().reference(forURL: "gs://slugbug-....appspot.com") // dots intentional
let imageRef = storageRef.child("testImage.jpg")
But the app crashes and I get the following message:
Application terminated due to uncaught exception "NSInvalidArgumentException", reason: "Bucket supplied: slugbug -... appspot.com does not match storage stuff current instance: (null) '
Even if I use
let storageRef = FIRStorage().reference()
The bucket is zero.
Why?
+3
source to share
3 answers
Use work with code below
// 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
}
})
+2
source to share