FIRStorageConstants.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. @class FIRStorageDownloadTask;
  18. @class FIRStorageMetadata;
  19. @class FIRStorageTaskSnapshot;
  20. @class FIRStorageUploadTask;
  21. NS_ASSUME_NONNULL_BEGIN
  22. /**
  23. * NSString typedef representing a task listener handle.
  24. */
  25. typedef NSString *FIRStorageHandle NS_SWIFT_NAME(StorageHandle);
  26. /**
  27. * Block typedef typically used when downloading data.
  28. * @param data The data returned by the download, or nil if no data available or download failed.
  29. * @param error The error describing failure, if one occurred.
  30. */
  31. typedef void (^FIRStorageVoidDataError)(NSData *_Nullable data, NSError *_Nullable error)
  32. NS_SWIFT_NAME(StorageVoidDataError);
  33. /**
  34. * Block typedef typically used when performing "binary" async operations such as delete,
  35. * where the operation either succeeds without an error or fails with an error.
  36. * @param error The error describing failure, if one occurred.
  37. */
  38. typedef void (^FIRStorageVoidError)(NSError *_Nullable error) NS_SWIFT_NAME(StorageVoidError);
  39. /**
  40. * Block typedef typically used when retrieving metadata.
  41. * @param metadata The metadata returned by the operation, if metadata exists.
  42. */
  43. typedef void (^FIRStorageVoidMetadata)(FIRStorageMetadata *_Nullable metadata)
  44. NS_SWIFT_NAME(StorageVoidMetadata);
  45. /**
  46. * Block typedef typically used when retrieving metadata with the possibility of an error.
  47. * @param metadata The metadata returned by the operation, if metadata exists.
  48. * @param error The error describing failure, if one occurred.
  49. */
  50. typedef void (^FIRStorageVoidMetadataError)(FIRStorageMetadata *_Nullable metadata,
  51. NSError *_Nullable error)
  52. NS_SWIFT_NAME(StorageVoidMetadataError);
  53. /**
  54. * Block typedef typically used to asynchronously return a storage task snapshot.
  55. * @param snapshot The returned task snapshot.
  56. */
  57. typedef void (^FIRStorageVoidSnapshot)(FIRStorageTaskSnapshot *snapshot)
  58. NS_SWIFT_NAME(StorageVoidSnapshot);
  59. /**
  60. * Block typedef typically used when retrieving a download URL.
  61. * @param URL The download URL associated with the operation.
  62. * @param error The error describing failure, if one occurred.
  63. */
  64. typedef void (^FIRStorageVoidURLError)(NSURL *_Nullable URL, NSError *_Nullable error)
  65. NS_SWIFT_NAME(StorageVoidURLError);
  66. /**
  67. * Enum representing the upload and download task status.
  68. */
  69. typedef NS_ENUM(NSInteger, FIRStorageTaskStatus) {
  70. /**
  71. * Unknown task status.
  72. */
  73. FIRStorageTaskStatusUnknown,
  74. /**
  75. * Task is being resumed.
  76. */
  77. FIRStorageTaskStatusResume,
  78. /**
  79. * Task reported a progress event.
  80. */
  81. FIRStorageTaskStatusProgress,
  82. /**
  83. * Task is paused.
  84. */
  85. FIRStorageTaskStatusPause,
  86. /**
  87. * Task has completed successfully.
  88. */
  89. FIRStorageTaskStatusSuccess,
  90. /**
  91. * Task has failed and is unrecoverable.
  92. */
  93. FIRStorageTaskStatusFailure
  94. } NS_SWIFT_NAME(StorageTaskStatus);
  95. /**
  96. * Firebase Storage error domain.
  97. */
  98. FOUNDATION_EXPORT NSString *const FIRStorageErrorDomain NS_SWIFT_NAME(StorageErrorDomain);
  99. /**
  100. * Enum representing the errors raised by Firebase Storage.
  101. */
  102. typedef NS_ENUM(NSInteger, FIRStorageErrorCode) {
  103. /** An unknown error occurred. */
  104. FIRStorageErrorCodeUnknown = -13000,
  105. /** No object exists at the desired reference. */
  106. FIRStorageErrorCodeObjectNotFound = -13010,
  107. /** No bucket is configured for Firebase Storage. */
  108. FIRStorageErrorCodeBucketNotFound = -13011,
  109. /** No project is configured for Firebase Storage. */
  110. FIRStorageErrorCodeProjectNotFound = -13012,
  111. /**
  112. * Quota on your Firebase Storage bucket has been exceeded.
  113. * If you're on the free tier, upgrade to a paid plan.
  114. * If you're on a paid plan, reach out to Firebase support.
  115. */
  116. FIRStorageErrorCodeQuotaExceeded = -13013,
  117. /** User is unauthenticated. Authenticate and try again. */
  118. FIRStorageErrorCodeUnauthenticated = -13020,
  119. /**
  120. * User is not authorized to perform the desired action.
  121. * Check your rules to ensure they are correct.
  122. */
  123. FIRStorageErrorCodeUnauthorized = -13021,
  124. /**
  125. * The maximum time limit on an operation (upload, download, delete, etc.) has been exceeded.
  126. * Try uploading again.
  127. */
  128. FIRStorageErrorCodeRetryLimitExceeded = -13030,
  129. /**
  130. * File on the client does not match the checksum of the file received by the server.
  131. * Try uploading again.
  132. */
  133. FIRStorageErrorCodeNonMatchingChecksum = -13031,
  134. /**
  135. * Size of the downloaded file exceeds the amount of memory allocated for the download.
  136. * Increase memory cap and try downloading again.
  137. */
  138. FIRStorageErrorCodeDownloadSizeExceeded = -13032,
  139. /** User cancelled the operation. */
  140. FIRStorageErrorCodeCancelled = -13040,
  141. /** An invalid argument was provided. */
  142. FIRStorageErrorCodeInvalidArgument = -13050
  143. } NS_SWIFT_NAME(StorageErrorCode);
  144. NS_ASSUME_NONNULL_END