本文介绍了FirebaseStorage中的图片网址不存在。,ResponseErrorDomain = com.google.HTTPStatus,ResponseErrorCode = 404}?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有代码可以将多个图像保存到firebase中。我更新了我的pod,之后我不得不更改我的downloadURL代码。这样做之后,网址中没有显示网址,也没有显示网页的帖子部分。这个问题似乎与相似。在控制台中我收到以下错误:

I have code which saves multiple images into firebase. I updated my pods, and after this I had to change my downloadURL code. After doing so the urls are not showing up in the database, neither is the "post section of it. This questions seems to be similar to this one. In the console I am getting the following errors:

And:

这些都发生在我按下一个将数据发送到firebase的按钮之后。
以下是有问题的代码:

These both happen after I press a button which send the data to firebase.Below is the problematic code:

第1区:

storageRef.downloadURL { (url, error) in

       if error != nil {
           print("Failed to download url:", error!)
           return
       }

       let imageUrl = "\(String(describing: url))"
            postRef.child(autoID).setValue(imageUrl)
        }

第2区:

    storageRef.downloadURL { (url, error) in

        if error != nil {
           print("Failed to download url:", error!)
               return
          }

      let imageUrl = "\(String(describing: url))"
//           let value = ["Image\(self.number)": imageUrl]  as [String : Any]
                 let value = [autoID: imageUrl]  as [String : Any]
                     postRef.updateChildValues(value)
                    }

在此先感谢您的帮助!

推荐答案

您可能正在使用不同的URL存储参考来放置数据方法这两个块是

You are probably using a different URL storage ref for the put data method the two blocks are within.

您可能会遇到类似这样的情况: childStorageRef 与storageRef不同:

You may have something like this where childStorageRef is a different ref than storageRef:

  childStorageRef.putData(uploadData, metadata: nil) { (metadata, err) in
    storageRef.downloadURL { (url, error) in

           if error != nil {
               print("Failed to download url:", error!)
               return
           }

           let imageUrl = "\(String(describing: url))"
                postRef.child(autoID).setValue(imageUrl)
            }
       }

将该引用更改为:

storageRef.putData(uploadData, metadata: nil) { (metadata, err) in
    storageRef.downloadURL { (url, error) in

       if error != nil {
           print("Failed to download url:", error!)
           return
       }

       let imageUrl = "\(String(describing: url))"
            postRef.child(autoID).setValue(imageUrl)
        }
   }

第2块也是如此。希望这会有所帮助!

Same thing for block 2. Hope this helps!

这篇关于FirebaseStorage中的图片网址不存在。,ResponseErrorDomain = com.google.HTTPStatus,ResponseErrorCode = 404}?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 10:22