NSLocalizedDescription =对象StringOfNumbers / post1 / StringOfNumbers.StringOfNumbers.jpg不存在

时间:2018-08-29 03:20:04

标签: ios swift firebase firebase-realtime-database firebase-storage

当我按下将我带到另一个视图控制器的按钮时,该控制器应该在firebase中下载图像的url,以便可以在imageView中显示它。我在控制台中收到以下消息:

  

错误域= FIRStorageErrorDomain代码= -13010“对象8MFEIQKyGuTnMI89kMG2E8D9IZ2 / post1 / 153511633.59902.jpg不存在。” UserInfo = {object = 8MFEIQKyGuTnMI89kGF2E8D9IZ2 / post1 / 1535511633.59902.jpg,ResponseBody = NoSuchKey指定的密钥不存在。不存在此类对象:prjpracticearraybasicimg.appspot.com/8MFEIQKyGuTnMI89kMGF2E8D9IZ2/pot1.jpg .COM,数据= <3c3f786d 6c207665 7273696f 6e3d2731 2e302720 656e636f 64696e67 3d275554 462d3827 3f3e3c45 72726f72 3e3c436f 64653e4e 6f537563 684b6579 3c2f436f 64653e3c 4d657373 6167653e 5466520 73706563 69666965 6420665 7920646f 6573206e 6f742065 78697374 2e3c2f4d 65737361 67653ec 44657461 696c733e 4e6f2073 75636820 6f626a65 63743a20 7975269 70726163 74696365 61727261 79626173 6963696d 67312e61 70707370 6f742e63 6f6d2f38 4d464549 514b7947 75546e4d 4938396b 4d474632 45384439 495a322f 706f7374 312f3135 33353531 31363333 2e353939 30322e6a 70673c2f 44657461 696c733e 3c2f4572 726f723type>,data_content charset = UTF-8,NSLocalizedDescription =对象8MFEIQKyGuTnMI89kMGF28D9IZ2 / post1 / 155511633.59902.jpg不存在。,ResponseErrorDomain = com.google.HTTPStatus,ResponseErrorCode = 404}

以下是我的代码:

import UIKit
import FirebaseStorage
import FirebaseDatabase
import FirebaseAuth
import Firebase

class PhaseOneViewController: UIViewController {

    @IBOutlet weak var p1ImageView: UIImageView!

    @IBAction func loadImages(_ sender: Any) {
        self.downloadImages(folderPath: "\(Storage.storage().reference().child((Auth.auth().currentUser?.uid)!).child("post\(takePicViewController().finalPost + PhotoArray.sharedInstance.numberPost)").child(ImageUploadManager().imageName))", success: { (img) in
            self.p1ImageView.image = img
            print(img)
        }) { (error) in
            print("here is errorrrrrrrrrrr",  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().child((Auth.auth().currentUser?.uid)!).child("post\(takePicViewController().finalPost + PhotoArray.sharedInstance.numberPost)").child(ImageUploadManager().imageName)
            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)
                        self.p1ImageView.image = myImage
                    }
                }
            }
        //}
    }
}

数据库树结构如下

  

帖子/ UID /帖子#/ ImageURLs-URL1,URL2 ...

感谢您的帮助!

0 个答案:

没有答案