如何在iOS上下载文件

问题描述 投票:0回答:1

我正在尝试通过从Firebase下载图像来更新用户个人资料图像,但问题是特定图像文件显示的是同一张图片,而不更新新的用户个人资料图像如何设置此代码以更新用户图像,以便每个用户都可以访问其个人资料图片,我是否必须切换到Firebase数据库或Firebase存储是否正常?

        let httpsReference = Storage.storage().reference(forURL: "https://firebasestorage.googleapis.com/v0/b/tunnel-vision-4bfd1.appspot.com")


             let data = Data()
             self.ProfileImage.image = UIImage(data: data)


             // Create local filesystem URL
        let localURL = URL(string: "gs://tunnel-vision-4bfd1.appspot.com")!

             // Download to the local filesystem
             let downloadTask = httpsReference.write(toFile: localURL) { url, error in
               if let error = error {
                 // Uh-oh, an error occurred!
               } else {
                 // Local file URL for "images/island.jpg" is returned
               }
             }

             let reference = Storage.storage().reference().child("image/jpeg")

                 // UIImageView in your ViewController
                 let imageView: UIImageView = self.ProfileImage

                 // Placeholder image
                 let placeholderImage = UIImage(named: "image/jpeg")
             imageView.sd_setImage(with: localURL, placeholderImage: placeholderImage)


                                                   return
                                                                }
ios firebase download firebase-storage
1个回答
1
投票
© www.soinside.com 2019 - 2024. All rights reserved.