繁体   English   中英

Firebase存储无法显示图像

[英]Firebase storage not displaying image

在写问题之前,我会说我是iOS开发和firebase中的新手:)这就是为什么我提前为一个愚蠢的问题道歉:)

当我以编程方式从firebase存储加载profile.png图像时,它正确加载而没有任何问题。

static func getUserImage(_ uid: String, completion: @escaping (UIImage?, NSError?) -> Void) {
        // Create a reference to the file you want to download.
        let storage = FIRStorage.storage()
        let userUID: String = String(describing: uid)
        let storageRef = storage.reference(forURL: "...some address...")
        let downloadRef = storageRef.child("\(userUID)/profilePhoto.png")

        // Download in memory with a maximum allowed size of 10MB (10 * 1024 * 1024 bytes).
        downloadRef.data(withMaxSize: 10 * 1024 * 1024) {
            data, error in
            guard let data = data, error == nil else {
                NSLog("Retrieve image failed:\n\(error?.localizedDescription)")
                completion(nil, error as! NSError)
                return
            }
            guard let image = UIImage(data: data) else {
                NSLog("Image decoding failed:\n\(data)")
                completion(nil, nil)
                return
            }
            assert(error == nil)
            completion(image, nil)
        }
    }

但是当我在浏览器中访问firebase存储并尝试通过uid手动从列表中搜索它时我找不到它 - 它不存在。 你能解释一下我怎么可能吗? 仅存在于firebase存储中的多个图像存在问题。

先感谢您!

文件夹名称应以大写字母开头。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM