【问题标题】:Firebase manage download API not availableFirebase 管理下载 API 不可用
【发布时间】:2016-07-05 10:52:47
【问题描述】:

我正在尝试使用此处记录的暂停、恢复和取消 API 管理来自 Firebase 存储的下载:

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

}

【问题讨论】:

  • 你能为我们粘贴完整的pathReference初始化吗?
  • 谢谢,更新问题

标签: swift firebase firebase-storage


【解决方案1】:

cancel、pause 或 resume 方法用于 FIRStorageDownloadTask 类,该类由 writeToFile method 返回,因此,在您的情况下:

let task = pathReference!.writeToFile(saveLocatio.... task.pause() task.cancel() task.resume()

应该有效

祝你好运!

【讨论】:

  • 谢谢!我想我应该阅读文档的前面部分:s
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-03
  • 2015-08-15
  • 2015-04-27
  • 1970-01-01
  • 2016-09-02
  • 1970-01-01
相关资源
最近更新 更多