FIRStorageConstants.h 5.3 KB

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