StorageDownloadTask.swift 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2022 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. import Foundation
  15. import FirebaseStorageInternal
  16. /**
  17. * StorageDownloadTask implements resumable downloads from an object in Firebase Storage.
  18. * Downloads can be returned on completion with a completion handler, and can be monitored
  19. * by attaching observers, or controlled by calling StorageTask#pause, StorageTask#resume,
  20. * or FIRIMPLStorageTask#cancel.
  21. * Downloads can currently be returned as Data in memory, or as an URL to a file on disk.
  22. * Downloads are performed on a background queue, and callbacks are raised on the developer
  23. * specified callbackQueue in Storage, or the main queue if left unspecified.
  24. * Currently all uploads must be initiated and managed on the main queue.
  25. */
  26. @objc(FIRStorageDownloadTask) open class StorageDownloadTask: StorageObservableTask,
  27. StorageTaskManagement {
  28. /**
  29. * Prepares a task and begins execution.
  30. */
  31. @objc open func enqueue() {
  32. (impl as! FIRIMPLStorageDownloadTask).enqueue()
  33. }
  34. /**
  35. * Pauses a task currently in progress.
  36. */
  37. @objc open func pause() {
  38. (impl as! FIRIMPLStorageDownloadTask).pause()
  39. }
  40. /**
  41. * Pauses a task currently in progress.
  42. */
  43. @objc open func cancel() {
  44. (impl as! FIRIMPLStorageDownloadTask).cancel()
  45. }
  46. /**
  47. * Pauses a task currently in progress.
  48. */
  49. @objc open func resume() {
  50. (impl as! FIRIMPLStorageDownloadTask).resume()
  51. }
  52. internal init(_ impl: FIRIMPLStorageDownloadTask) {
  53. super.init(impl: impl)
  54. }
  55. }