我正在尝试使用此处记录的暂停、恢复和取消 API 来管理来自 Firebase Storage 的下载:
https://firebase.google.com/docs/storage/ios/download-files#manage_downloads
我的下载工作正常,但我无法访问这些功能,有人知道如何访问这些功能吗?
var storageRef: FIRStorageReference? = nil
var pathReference: FIRStorageReference? = nil
func downloadImage(imageLocation: String) {
let saveLocation = NSURL(fileURLWithPath: String(HelperFunctions.getDocumentsDirectory()) + "/" + imageLocation)
storageRef = FIRStorage.storage().reference()
pathReference = storageRef!.child(imageLocation)
pathReference!.writeToFile(saveLocation) { (URL, error) -> Void in
}
最佳答案
取消、暂停或恢复方法适用于 FIRStorageDownloadTask 类,该类由 writeToFile method 返回。所以,就你而言:
让任务 = pathReference!.writeToFile(saveLocatio...
任务.暂停()
任务.取消()
任务.resume()
应该可以工作
祝你好运!
关于swift - Firebase 管理下载 API 不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38201588/