gpt4 book ai didi

ios - Firebase 存储完成从未触发/被回调

转载 作者:行者123 更新时间:2023-11-29 05:41:24 24 4
gpt4 key购买 nike

当我尝试将图像上传到 Firebase Storage 时遇到奇怪的问题。本质上,我可以将文件上传到存储,但完成回调没有发生。我需要这个回调来获取正在上传的文件的存储 URL。

设置

let storage = Storage.storage()
let storageRef = storage.reference()
let data = curImg?.pngData()
let riversRef = storageRef.child("userUploads/Search/"+id+".png")

上传功能

let uploadTask = riversRef.putData(data!, metadata: nil) { (metadata, error) in
print("FIN") // NEVER PRINTS
print("DONE",metadata,error) // NEVER PRINTS
}

This doesn't ever print anything

使用观察

uploadTask.observe(.success) { snapshot in
// Upload completed successfully
print("SUCCESS") // NEVER PRINTS
riversRef.downloadURL(completion: { (url, error) in
print("A") // NEVER PRINTS
print(url,error) // NEVER PRINTS
})
}

This doesn't ever print anything

更狡猾一点

uploadTask.observe(.progress) { snapshot in
print(snapshot) // PRINTS!
if (Double(snapshot.progress!.completedUnitCount) == Double(snapshot.progress!.totalUnitCount)) {
print("HERE") // PRINTS!!
riversRef.downloadURL(completion: { (url, error) in
print("B") // NEVER PRINTS
print(url,error) // NEVER PRINTS
})
}
}

Is able to print progress and I am able to figure out when it finally completes, but I can never get the downloadURL to complete :(

编辑我尝试更新 Pod 并再次安装,但没有帮助。

最佳答案

如果您遇到这个奇怪的问题,则代码没有任何问题。我必须使用 pod 'FirebaseInstanceID', '2.0.0' 删除 Podfile.lock 来回滚所有 pod。最新版本的 Firebase/Xcode 中出现奇怪的错误...?

关于ios - Firebase 存储完成从未触发/被回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56513314/

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