StorageUploadTask.swift 1.9 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. * `StorageUploadTask` implements resumable uploads to a file in Firebase Storage.
  18. * Uploads can be returned on completion with a completion callback, and can be monitored
  19. * by attaching observers, or controlled by calling `pause()`, `resume()`,
  20. * or `cancel()`.
  21. * Uploads can be initialized from `Data` in memory, or a URL to a file on disk.
  22. * Uploads are performed on a background queue, and callbacks are raised on the developer
  23. * specified `callbackQueue` in Storage, or the main queue if unspecified.
  24. * Currently all uploads must be initiated and managed on the main queue.
  25. */
  26. @objc(FIRStorageUploadTask) open class StorageUploadTask: StorageObservableTask,
  27. StorageTaskManagement {
  28. /**
  29. * Prepares a task and begins execution.
  30. */
  31. @objc open func enqueue() {
  32. (impl as! FIRIMPLStorageUploadTask).enqueue()
  33. }
  34. /**
  35. * Pauses a task currently in progress.
  36. */
  37. @objc open func pause() {
  38. (impl as! FIRIMPLStorageUploadTask).pause()
  39. }
  40. /**
  41. * Cancels a task.
  42. */
  43. @objc open func cancel() {
  44. (impl as! FIRIMPLStorageUploadTask).cancel()
  45. }
  46. /**
  47. * Resumes a paused task.
  48. */
  49. @objc open func resume() {
  50. (impl as! FIRIMPLStorageUploadTask).resume()
  51. }
  52. internal init(_ impl: FIRIMPLStorageUploadTask) {
  53. super.init(impl: impl)
  54. }
  55. }