FIRStorage.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. /** Project version string for FirebaseStorage. */
  22. FOUNDATION_EXPORT const char *const FIRStorageVersionString NS_SWIFT_NAME(StorageVersionString);
  23. /**
  24. * FirebaseStorage is a service that supports uploading and downloading binary objects,
  25. * such as images, videos, and other files to Google Cloud Storage.
  26. *
  27. * If you call [FIRStorage storage], the instance will initialize with the default FIRApp,
  28. * [FIRApp defaultApp], and the storage location will come from the provided
  29. * GoogleService-Info.plist.
  30. *
  31. * If you call [FIRStorage storageForApp:] and provide a custom instance of FIRApp,
  32. * the storage location will be specified via the FIROptions#storageBucket property.
  33. */
  34. NS_SWIFT_NAME(Storage)
  35. @interface FIRStorage : NSObject
  36. /**
  37. * Creates an instance of FIRStorage, configured with the default FIRApp.
  38. * @return the FIRStorage instance, initialized with the default FIRApp.
  39. */
  40. + (instancetype)storage NS_SWIFT_NAME(storage());
  41. /**
  42. * Creates an instance of FIRStorage, configured with the custom FIRApp @a app.
  43. * @param app The custom FIRApp used for initialization.
  44. * @return the FIRStorage instance, initialized with the custom FIRApp.
  45. */
  46. + (instancetype)storageForApp:(FIRApp *)app NS_SWIFT_NAME(storage(app:));
  47. /**
  48. * Creates an instance of FIRStorage, configured with a custom storage bucket @a url.
  49. * @param url The gs:// url to your Firebase Storage Bucket.
  50. * @return the FIRStorage instance, initialized with the custom FIRApp.
  51. */
  52. + (instancetype)storageWithURL:(NSString *)url NS_SWIFT_NAME(storage(url:));
  53. /**
  54. * Creates an instance of FIRStorage, configured with a custom FIRApp @a app and a custom storage
  55. * bucket @a url.
  56. * @param app The custom FIRApp used for initialization.
  57. * @param url The gs:// url to your Firebase Storage Bucket.
  58. * @return the FIRStorage instance, initialized with the custom FIRApp.
  59. */
  60. + (instancetype)storageForApp:(FIRApp *)app URL:(NSString *)url NS_SWIFT_NAME(storage(app:url:));
  61. - (instancetype)init NS_UNAVAILABLE;
  62. /**
  63. * The Firebase App associated with this Firebase Storage instance.
  64. */
  65. @property(strong, nonatomic, readonly) FIRApp *app;
  66. /**
  67. * Maximum time in seconds to retry an upload if a failure occurs.
  68. * Defaults to 10 minutes (600 seconds).
  69. */
  70. @property NSTimeInterval maxUploadRetryTime;
  71. /**
  72. * Maximum time in seconds to retry a download if a failure occurs.
  73. * Defaults to 10 minutes (600 seconds).
  74. */
  75. @property NSTimeInterval maxDownloadRetryTime;
  76. /**
  77. * Maximum time in seconds to retry operations other than upload and download if a failure occurs.
  78. * Defaults to 2 minutes (120 seconds).
  79. */
  80. @property NSTimeInterval maxOperationRetryTime;
  81. /**
  82. * Queue that all developer callbacks are fired on. Defaults to the main queue.
  83. */
  84. @property(strong, nonatomic) dispatch_queue_t callbackQueue;
  85. /**
  86. * Creates a FIRStorageReference initialized at the root Firebase Storage location.
  87. * @return An instance of FIRStorageReference initialized at the root.
  88. */
  89. - (FIRStorageReference *)reference;
  90. /**
  91. * Creates a FIRStorageReference given a gs:// or https:// URL pointing to a Firebase Storage
  92. * location. For example, you can pass in an https:// download URL retrieved from
  93. * [FIRStorageReference downloadURLWithCompletion] or the gs:// URI from
  94. * [FIRStorageReference description].
  95. * @param string A gs:// or https:// URL to initialize the reference with.
  96. * @return An instance of FIRStorageReference at the given child path.
  97. * @throws Throws an exception if passed in URL is not associated with the FIRApp used to initialize
  98. * this FIRStorage.
  99. */
  100. - (FIRStorageReference *)referenceForURL:(NSString *)string;
  101. /**
  102. * Creates a FIRStorageReference initialized at a child Firebase Storage location.
  103. * @param string A relative path from the root to initialize the reference with,
  104. * for instance @"path/to/object".
  105. * @return An instance of FIRStorageReference at the given child path.
  106. */
  107. - (FIRStorageReference *)referenceWithPath:(NSString *)string;
  108. @end
  109. NS_ASSUME_NONNULL_END