gpt4 book ai didi

ios - 如何在Firebase中使用writeToFile来处理超出最大大小的情况?

转载 作者:行者123 更新时间:2023-11-30 13:04:53 26 4
gpt4 key购买 nike

我需要有关从 Firebase 数据库加载图像的帮助。我已将 2 张图片上传到 firebase。当我想加载图像时。出现这个错误

  Attempeted to download object with size of 1050168 bytes, which exceeds the maximum size of 1048576 bytes. Consider raising the maximum download size, or using [FIRStorageReference writeToFile:]

但是,有时我可以加载 2 个图像,有时会卡住。

我对 Swift 和 Firebase 还很陌生。

 func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

storageRef = FIRStorage.storage().referenceForURL(toDoList[indexPath.row].imageName)
let storageRef1 = FIRStorage.storage().referenceForURL(toDoList[indexPath.row].secondPhoto)
let itemSelected = toDoList[indexPath.row]
storageRef.dataWithMaxSize(1 * 1024 * 1024) { (data, error) in
if error == nil
{
dispatch_async(dispatch_get_main_queue(), {
if let data = data
{
storageRef1.dataWithMaxSize(1 * 1024 * 1024) { (data1, error) in

if error == nil
{
dispatch_async(dispatch_get_main_queue(), {
if let data1 = data1
{
let detailVC:DetailViewController = self.storyboard?.instantiateViewControllerWithIdentifier("DetailViewController") as! DetailViewController
print(itemSelected.eventID)
detailVC.eventIDfromDetail = itemSelected.eventID
detailVC.titleEvent = itemSelected.title
detailVC.staffEvent = itemSelected.staff
detailVC.locationEvent = itemSelected.location
detailVC.startEvent = itemSelected.starts
detailVC.endEvent = itemSelected.ends
detailVC.repeatEvent = itemSelected.rpeat
detailVC.imageDetail = UIImage(data: data)!
detailVC.descriptionDetail = itemSelected.description
detailVC.secondPhotoEvent = UIImage(data: data1)!
detailVC.key = itemSelected.key
detailVC.isFinish = itemSelected.isCompleted
self.presentViewController(detailVC, animated: true, completion: nil)
}
})
}
else
{
print(error!.localizedDescription)
}

}}
})
}
else
{
print(error!.localizedDescription)
}

}
}

最佳答案

看来您需要提高dataWithMaxSize。请注意,根据 Firebase 文档,您不要下载超出设备内存容量的文件,否则应用程序将崩溃。 Firebase 文档的链接 here .

关于ios - 如何在Firebase中使用writeToFile来处理超出最大大小的情况?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39517264/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com