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

前端 未结 3 558
日久生厌
日久生厌 2021-01-13 17:36

I have the following code:

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


        
相关标签:
3条回答
  • 2021-01-13 17:59

    Use below code work

     // 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
                   }
         })
    
    0 讨论(0)
  • 2021-01-13 18:01

    You are missing .storage().

    Check your line. It should be:

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

    Hope it helps

    0 讨论(0)
  • 2021-01-13 18:07

    I figured out the solution:

    I changed the code from:

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

    to:

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

    ... a very subtle but annoying bug

    0 讨论(0)
提交回复
热议问题