swift - Firebase 管理下载 API 不可用

标签 swift firebase firebase-storage

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

https://firebase.google.com/docs/storage/ios/download-files#manage_downloads

我的下载工作正常,但我无法访问这些功能,有人知道如何访问这些功能吗?

enter image description here

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/

相关文章:

javascript - 正确的查询结构。没有得到日志输出

node.js - 存储上的 Firebase 函数是否存在通配符?

node.js - 错误 : read ECONNRESET when resizing image with Firebase Cloud Functions

string - 从常量 Ints 创建 Range<String.Index>

swift - 内联 if 语句在 void 返回闭包中改变 inout 参数,奇怪的错误(错误 : type 'Int1' does not conform to protocol 'BooleanType' )

javascript - 我有一个想要搜索 Cloud Firestore 的体育项目(数组)列表。但是,数组的大小会有所不同

ios - 将文件上传到 s3,然后将 URL 存储在 Firebase 中 - Swift 2.2

ios - Swift 中的 CLPlacemark 崩溃

swift - 为什么 Swift 1.2 reduce 会强制我使用 combine : argument name?

firebase - 如何使用Flutter在Firestore中显示图像文件