0

If I use FirebaseUI to download images, can we manage(pause, stop or resume) downloads. And also if I need progress, can I get the progress? My main problem is, is there a way to manage downlaods as tasks with using FirebaseUI?

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
isuru
  • 3,385
  • 4
  • 27
  • 62

1 Answers1

0

Have you checked https://firebase.google.com/docs/storage/ios/download-files ? It has examples on how to manage the download and even get the progress, using FirebaseUI.

Manage Downloads In addition to starting downloads, you can pause, resume, and cancel downloads using the pause, resume, and cancel methods. These methods raise pause, resume, and cancel events that you can observe.

// Start downloading a file
let downloadTask = storageRef.child("images/mountains.jpg").write(toFile: localFile)

// Pause the download
downloadTask.pause()

// Resume the download
downloadTask.resume()

// Cancel the download
downloadTask.cancel()

Monitor Download Progress You can attach observers to FIRStorageDownloadTasks in order to monitor the progress of the download. Adding an observer returns a FIRStorageHandle that can be used to remove the observer.

// Add a progress observer to a download task
let observer = downloadTask.observe(.progress) { snapshot in
  // A progress event occurred
}
oeste
  • 1,389
  • 1
  • 8
  • 10
  • In FirebaseUI no need to create task. Just put the reference and set image to imageview. – isuru Jun 05 '18 at 06:07