我有一个应用程序,用户将图像发布到数据库中,然后当他按下按钮时转到新的VC。然后,当viewDidLoad时,它应运行下面的代码块(块1)。但是,当发生这种情况时,我会在控制台中看到很多长时间的错误提示。我该怎么办,这是什么意思?
错误域= FIRStorageErrorDomain代码= -13010“对象gs:/practicearraybasicimg1.appspot.com/ZubvhhWV4PcYn5EeKHIVf1nQn213/post0/1536537585.03625.jpg/0.jpg不存在。 UserInfo = {object = gs:/practicearraybasicimg1.appspot.com/ZubvhhWV4PcYn5EeKHIVf1nQn213/post0/1536537585.03625.jpg/0.jpg,ResponseBody =
NoSuchKey
指定的键不存在。不存在这样的对象:Practicearraybasicimg1.appspotcom。 GS:/practicearraybasicimg1.appspot.com/ZubvhhWV4PcYn5EeKHIVf1nQn213/post0/1536537585.03625.jpg/0.jpg,斗= practicearraybasicimg1.appspot.com,数据= <3c3f786d 6c207665 7273696f 6e3d2731 2e302720 656e636f 64696e67 3d275554 462d3827 3f3e3c45 72726f72 3e3436f 6463e4e 6f537563 684b6579 3c2f436f 64653e3c 4d657373 6167653e 54686520 73706563 69666965 64206b65 7920646f 6573206e 6f742065 78697374 2e3c2f4d 65737361 67653e3c 44657461 696c733e 4e6f2073 75636820 6f626a65 63743a20 79756269 70726163 74696365 61727261 79626173 6963696d 67312e61 70707370 6f742e63 6f6d2f67 733a2f79 75626970 72616374 69636561 72726179 62617369 63696d67 312e6170 7073706f 742e636f 6d2f5a75 62766868 57563450 63596e35 45654b48 49566631 6e516e32 31332f70 6f737430 2f313533 36353337 3538352e 30333632 352e6a70 672f302e 6a70673c 2f446574 61696c73 3e3c2f45 72726f72 3e>,data_content_type = application / xml; charset = UTF-8,NSLocalizedDescription =对象gs:/practicearraybasicimg1.appspot.com/ZubvhhWV4PcYn5EeKHIVf1nQn213/post0/1536537585.03625.jpg/0.jpg不存在。,ResponseErrorDomain = com.google.HTTPStatus,Response> ErrorCode = 404}
第1块:
override func viewDidLoad() {
super.viewDidLoad()
// downloadImages(ImageObject: takePicViewController().image())
let uid = Auth.auth().currentUser?.uid
let storageRef = Storage.storage().reference().child((Auth.auth().currentUser?.uid)!).child("post\(takePicViewController().finalPost + takePicViewController().postImage.numberPost)").child(ImageUploadManager().imageName)
let ref = Database.database().reference()
let childRef = ref.child("Posts").child(uid!).child("post\(takePicViewController().finalPost + takePicViewController().postImage.numberPost)")
let postRef = childRef.child("ImageUrl")
self.downloadImages(folderPath: "\(storageRef)", success: {
(img) in
print(img)
self.p1ImageView.image = img
}) { (error) in
print(error)
}
}
该功能如下所示:
func downloadImages(folderPath:String,success:@escaping (_ image:UIImage)->(),failure:@escaping (_ error:Error)->()){
for i in 0 ..< 194{
// Create a reference with an initial file path and name
let reference = Storage.storage().reference(withPath: "\(folderPath)/0.jpg")
reference.getData(maxSize: (3 * 1024 * 1024)) { (data, error) in
if let _error = error {
print(_error)
failure(_error)
} else {
if let _data = data {
let myImage:UIImage! = UIImage(data: _data)
success(myImage)
}
}
}
}
}