Ben Sullivan
Ben Sullivan

Reputation: 2154

Firebase manage download API not available

I am trying to manage downloads from Firebase Storage using the Pause, Resume and Cancel API which is documented here:

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

My downloads are working perfectly but I have no access to any of these functions, does anybody know how to access these?

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

}

Upvotes: 2

Views: 191

Answers (1)

Ber.to
Ber.to

Reputation: 1104

The cancel, pause or resume methods are for the FIRStorageDownloadTask class, which is returned by the writeToFile method so, in your case:

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

Should work

Best of luck!

Upvotes: 3

Related Questions