FIRStorage.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #import "FIRStorageConstants.h"
  18. @class FIRApp;
  19. @class FIRStorageReference;
  20. NS_ASSUME_NONNULL_BEGIN
  21. /**
  22. * FirebaseStorage is a service that supports uploading and downloading binary objects,
  23. * such as images, videos, and other files to Google Cloud Storage.
  24. *
  25. * If you call [FIRStorage storage], the instance will initialize with the default FIRApp,
  26. * [FIRApp defaultApp], and the storage location will come from the provided
  27. * GoogleService-Info.plist.
  28. *
  29. * If you call [FIRStorage storageForApp:] and provide a custom instance of FIRApp,
  30. * the storage location will be specified via the FIROptions#storageBucket property.
  31. */
  32. NS_SWIFT_NAME(Storage)
  33. @interface FIRStorage : NSObject
  34. /**
  35. * Creates an instance of FIRStorage, configured with the default FIRApp.
  36. * @return the FIRStorage instance, initialized with the default FIRApp.
  37. */
  38. + (instancetype)storage NS_SWIFT_NAME(storage());
  39. /**
  40. * Creates an instance of FIRStorage, configured with the custom FIRApp @a app.
  41. * @param app The custom FIRApp used for initialization.
  42. * @return the FIRStorage instance, initialized with the custom FIRApp.
  43. */
  44. + (instancetype)storageForApp:(FIRApp *)app NS_SWIFT_NAME(storage(app:));
  45. /**
  46. * Creates an instance of FIRStorage, configured with a custom storage bucket @a url.
  47. * @param url The gs:// url to your Firebase Storage Bucket.
  48. * @return the FIRStorage instance, initialized with the custom FIRApp.
  49. */
  50. + (instancetype)storageWithURL:(NSString *)url NS_SWIFT_NAME(storage(url:));
  51. /**
  52. * Creates an instance of FIRStorage, configured with a custom FIRApp @a app and a custom storage
  53. * bucket @a url.
  54. * @param app The custom FIRApp used for initialization.
  55. * @param url The gs:// url to your Firebase Storage Bucket.
  56. * @return the FIRStorage instance, initialized with the custom FIRApp.
  57. */
  58. + (instancetype)storageForApp:(FIRApp *)app URL:(NSString *)url NS_SWIFT_NAME(storage(app:url:));
  59. - (instancetype)init NS_UNAVAILABLE;
  60. /**
  61. * The Firebase App associated with this Firebase Storage instance.
  62. */
  63. @property(strong, nonatomic, readonly) FIRApp *app;
  64. /**
  65. * Maximum time in seconds to retry an upload if a failure occurs.
  66. * Defaults to 10 minutes (600 seconds).
  67. */
  68. @property NSTimeInterval maxUploadRetryTime;
  69. /**
  70. * Maximum time in seconds to retry a download if a failure occurs.
  71. * Defaults to 10 minutes (600 seconds).
  72. */
  73. @property NSTimeInterval maxDownloadRetryTime;
  74. /**
  75. * Maximum time in seconds to retry operations other than upload and download if a failure occurs.
  76. * Defaults to 2 minutes (120 seconds).
  77. */
  78. @property NSTimeInterval maxOperationRetryTime;
  79. /**
  80. * Queue that all developer callbacks are fired on. Defaults to the main queue.
  81. */
  82. @property(strong, nonatomic) dispatch_queue_t callbackQueue;
  83. /**
  84. * Creates a FIRStorageReference initialized at the root Firebase Storage location.
  85. * @return An instance of FIRStorageReference initialized at the root.
  86. */
  87. - (FIRStorageReference *)reference;
  88. /**
  89. * Creates a FIRStorageReference given a gs:// or https:// URL pointing to a Firebase Storage
  90. * location. For example, you can pass in an https:// download URL retrieved from
  91. * [FIRStorageReference downloadURLWithCompletion] or the gs:// URI from
  92. * [FIRStorageReference description].
  93. * @param string A gs:// or https:// URL to initialize the reference with.
  94. * @return An instance of FIRStorageReference at the given child path.
  95. * @throws Throws an exception if passed in URL is not associated with the FIRApp used to initialize
  96. * this FIRStorage.
  97. */
  98. - (FIRStorageReference *)referenceForURL:(NSString *)string;
  99. /**
  100. * Creates a FIRStorageReference initialized at a child Firebase Storage location.
  101. * @param string A relative path from the root to initialize the reference with,
  102. * for instance @"path/to/object".
  103. * @return An instance of FIRStorageReference at the given child path.
  104. */
  105. - (FIRStorageReference *)referenceWithPath:(NSString *)string;
  106. /**
  107. * Configures the Storage SDK to use an emulated backend instead of the default remote backend.
  108. */
  109. - (void)useEmulatorWithHost:(NSString *)host port:(NSInteger)port;
  110. @end
  111. NS_ASSUME_NONNULL_END