@react-native-firebase/storage 24.1.0 → 25.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/{lib → dist/module}/StorageDownloadTask.js +4 -3
  3. package/dist/module/StorageDownloadTask.js.map +1 -0
  4. package/{lib → dist/module}/StorageListResult.js +13 -8
  5. package/dist/module/StorageListResult.js.map +1 -0
  6. package/dist/module/StorageReference.js +270 -0
  7. package/dist/module/StorageReference.js.map +1 -0
  8. package/{lib → dist/module}/StorageStatics.js +5 -16
  9. package/dist/module/StorageStatics.js.map +1 -0
  10. package/{lib → dist/module}/StorageTask.js +82 -71
  11. package/dist/module/StorageTask.js.map +1 -0
  12. package/{lib → dist/module}/StorageUploadTask.js +4 -3
  13. package/dist/module/StorageUploadTask.js.map +1 -0
  14. package/dist/module/index.js +29 -0
  15. package/dist/module/index.js.map +1 -0
  16. package/{lib/modular/index.js → dist/module/modular.js} +65 -79
  17. package/dist/module/modular.js.map +1 -0
  18. package/dist/module/namespaced.js +192 -0
  19. package/dist/module/namespaced.js.map +1 -0
  20. package/dist/module/package.json +1 -0
  21. package/dist/module/types/internal.js +4 -0
  22. package/dist/module/types/internal.js.map +1 -0
  23. package/dist/module/types/namespaced.js +64 -0
  24. package/dist/module/types/namespaced.js.map +1 -0
  25. package/dist/module/types/storage.js +139 -0
  26. package/dist/module/types/storage.js.map +1 -0
  27. package/dist/module/utils.js +105 -0
  28. package/dist/module/utils.js.map +1 -0
  29. package/dist/module/version.js +5 -0
  30. package/dist/module/version.js.map +1 -0
  31. package/dist/module/web/RNFBStorageModule.android.js +6 -0
  32. package/dist/module/web/RNFBStorageModule.android.js.map +1 -0
  33. package/dist/module/web/RNFBStorageModule.ios.js +6 -0
  34. package/dist/module/web/RNFBStorageModule.ios.js.map +1 -0
  35. package/{lib → dist/module}/web/RNFBStorageModule.js +115 -197
  36. package/dist/module/web/RNFBStorageModule.js.map +1 -0
  37. package/dist/typescript/lib/StorageDownloadTask.d.ts +6 -0
  38. package/dist/typescript/lib/StorageDownloadTask.d.ts.map +1 -0
  39. package/dist/typescript/lib/StorageListResult.d.ts +13 -0
  40. package/dist/typescript/lib/StorageListResult.d.ts.map +1 -0
  41. package/dist/typescript/lib/StorageReference.d.ts +87 -0
  42. package/dist/typescript/lib/StorageReference.d.ts.map +1 -0
  43. package/dist/typescript/lib/StorageStatics.d.ts +2 -0
  44. package/dist/typescript/lib/StorageStatics.d.ts.map +1 -0
  45. package/dist/typescript/lib/StorageTask.d.ts +43 -0
  46. package/dist/typescript/lib/StorageTask.d.ts.map +1 -0
  47. package/dist/typescript/lib/StorageUploadTask.d.ts +6 -0
  48. package/dist/typescript/lib/StorageUploadTask.d.ts.map +1 -0
  49. package/dist/typescript/lib/index.d.ts +6 -0
  50. package/dist/typescript/lib/index.d.ts.map +1 -0
  51. package/dist/typescript/lib/modular.d.ts +154 -0
  52. package/dist/typescript/lib/modular.d.ts.map +1 -0
  53. package/dist/typescript/lib/namespaced.d.ts +12 -0
  54. package/dist/typescript/lib/namespaced.d.ts.map +1 -0
  55. package/dist/typescript/lib/types/internal.d.ts +131 -0
  56. package/dist/typescript/lib/types/internal.d.ts.map +1 -0
  57. package/dist/typescript/lib/types/namespaced.d.ts +1122 -0
  58. package/dist/typescript/lib/types/namespaced.d.ts.map +1 -0
  59. package/dist/typescript/lib/types/storage.d.ts +338 -0
  60. package/dist/typescript/lib/types/storage.d.ts.map +1 -0
  61. package/dist/typescript/lib/utils.d.ts +20 -0
  62. package/dist/typescript/lib/utils.d.ts.map +1 -0
  63. package/dist/typescript/lib/version.d.ts +2 -0
  64. package/dist/typescript/lib/version.d.ts.map +1 -0
  65. package/dist/typescript/lib/web/RNFBStorageModule.android.d.ts +3 -0
  66. package/dist/typescript/lib/web/RNFBStorageModule.android.d.ts.map +1 -0
  67. package/dist/typescript/lib/web/RNFBStorageModule.d.ts +142 -0
  68. package/dist/typescript/lib/web/RNFBStorageModule.d.ts.map +1 -0
  69. package/dist/typescript/lib/web/RNFBStorageModule.ios.d.ts +3 -0
  70. package/dist/typescript/lib/web/RNFBStorageModule.ios.d.ts.map +1 -0
  71. package/dist/typescript/package.json +1 -0
  72. package/lib/StorageDownloadTask.ts +30 -0
  73. package/lib/StorageListResult.ts +61 -0
  74. package/lib/{StorageReference.js → StorageReference.ts} +103 -61
  75. package/lib/StorageStatics.ts +19 -0
  76. package/lib/StorageTask.ts +336 -0
  77. package/lib/StorageUploadTask.ts +30 -0
  78. package/lib/index.ts +27 -0
  79. package/lib/modular.ts +401 -0
  80. package/lib/{index.js → namespaced.ts} +70 -28
  81. package/lib/types/internal.ts +189 -0
  82. package/lib/{index.d.ts → types/namespaced.ts} +111 -49
  83. package/lib/types/storage.ts +417 -0
  84. package/lib/{utils.js → utils.ts} +62 -15
  85. package/lib/version.ts +2 -0
  86. package/lib/web/RNFBStorageModule.android.ts +3 -0
  87. package/lib/web/RNFBStorageModule.ios.ts +3 -0
  88. package/lib/web/RNFBStorageModule.ts +557 -0
  89. package/package.json +41 -7
  90. package/tsconfig.json +23 -0
  91. package/typedoc.json +1 -1
  92. package/lib/modular/index.d.ts +0 -276
  93. package/lib/version.js +0 -2
  94. package/lib/web/RNFBStorageModule.android.js +0 -2
  95. package/lib/web/RNFBStorageModule.ios.js +0 -2
@@ -0,0 +1,1122 @@
1
+ import type { ReactNativeFirebase } from '@react-native-firebase/app';
2
+ /**
3
+ * Firebase Cloud Storage package for React Native.
4
+ *
5
+ * #### Example 1
6
+ *
7
+ * Access the firebase export from the `storage` package:
8
+ *
9
+ * ```js
10
+ * import { firebase } from '@react-native-firebase/storage';
11
+ *
12
+ * // firebase.storage().X
13
+ * ```
14
+ *
15
+ * #### Example 2
16
+ *
17
+ * Using the default export from the `storage` package:
18
+ *
19
+ * ```js
20
+ * import storage from '@react-native-firebase/storage';
21
+ *
22
+ * // storage().X
23
+ * ```
24
+ *
25
+ * #### Example 3
26
+ *
27
+ * Using the default export from the `app` package:
28
+ *
29
+ * ```js
30
+ * import firebase from '@react-native-firebase/app';
31
+ * import '@react-native-firebase/storage';
32
+ *
33
+ * // firebase.storage().X
34
+ * ```
35
+ *
36
+ * @firebase storage
37
+ */
38
+ /**
39
+ * @deprecated Use the exported types directly instead.
40
+ * FirebaseStorageTypes namespace is kept for backwards compatibility.
41
+ */
42
+ export declare namespace FirebaseStorageTypes {
43
+ type FirebaseModule = ReactNativeFirebase.FirebaseModule;
44
+ type NativeFirebaseError = ReactNativeFirebase.NativeFirebaseError;
45
+ /**
46
+ * Possible string formats used for uploading via `StorageReference.putString()`
47
+ *
48
+ * @deprecated Use the exported types directly instead. FirebaseStorageTypes namespace is kept for backwards compatibility.
49
+ *
50
+ * ```js
51
+ * firebase.storage.StringFormat;
52
+ * ```
53
+ */
54
+ export interface StringFormat {
55
+ /**
56
+ * Raw string format.
57
+ *
58
+ * #### Usage
59
+ *
60
+ * ```js
61
+ * firebase.storage.StringFormat.RAW;
62
+ * ```
63
+ *
64
+ * #### Example String Format
65
+ *
66
+ * ```js
67
+ * const sampleString = '<Foo Bar>';
68
+ * ```
69
+ */
70
+ RAW: 'raw';
71
+ /**
72
+ * Base64 string format.
73
+ *
74
+ * Learn more about Base64 [on the Mozilla Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding)
75
+ *
76
+ * #### Usage
77
+ *
78
+ * ```js
79
+ * firebase.storage.StringFormat.BASE64;
80
+ * ```
81
+ *
82
+ * #### Example String Format
83
+ *
84
+ * ```js
85
+ * const sampleString = 'PEZvbyBCYXI+';
86
+ * ```
87
+ *
88
+ */
89
+ BASE64: 'base64';
90
+ /**
91
+ * Base64Url string format.
92
+ *
93
+ * #### Usage
94
+ *
95
+ * ```js
96
+ * firebase.storage.StringFormat.BASE64URL;
97
+ * ```
98
+ *
99
+ * #### Example String Format
100
+ *
101
+ * ```js
102
+ * const sampleString = 'PEZvbyBCYXI-';
103
+ * ```
104
+ *
105
+ */
106
+ BASE64URL: 'base64url';
107
+ /**
108
+ * Data URL string format.
109
+ *
110
+ * #### Usage
111
+ *
112
+ * ```js
113
+ * firebase.storage.StringFormat.DATA_URL;
114
+ * ```
115
+ *
116
+ * #### Example String Format
117
+ *
118
+ * ```js
119
+ * const sampleString = 'data:text/plain;base64,PEZvbyBCYXI+';
120
+ * ```
121
+ */
122
+ DATA_URL: 'data_url';
123
+ }
124
+ /**
125
+ * An event to subscribe to that is triggered on a Upload or Download task.
126
+ *
127
+ * Event subscription is created via `StorageTask.on()`.
128
+ *
129
+ * @deprecated Use the exported types directly instead. FirebaseStorageTypes namespace is kept for backwards compatibility.
130
+ *
131
+ * ```js
132
+ * firebase.storage.TaskEvent;
133
+ * ```
134
+ */
135
+ /**
136
+ * An event that is triggered on a task.
137
+ *
138
+ * @deprecated Use the exported types directly instead. FirebaseStorageTypes namespace is kept for backwards compatibility.
139
+ */
140
+ export type TaskEvent = 'state_changed';
141
+ /**
142
+ * Static properties for task events (runtime object).
143
+ *
144
+ * @deprecated Use the exported types directly instead. FirebaseStorageTypes namespace is kept for backwards compatibility.
145
+ */
146
+ export interface TaskEventStatic {
147
+ STATE_CHANGED: TaskEvent;
148
+ }
149
+ /**
150
+ * A collection of properties that indicates the current tasks state.
151
+ *
152
+ * An event subscription is created via `StorageTask.on()`.
153
+ *
154
+ * @deprecated Use the exported types directly instead. FirebaseStorageTypes namespace is kept for backwards compatibility.
155
+ *
156
+ * ```js
157
+ * firebase.storage.TaskEvent;
158
+ * ```
159
+ */
160
+ export interface TaskState {
161
+ /**
162
+ * Task has been cancelled by the user.
163
+ */
164
+ CANCELLED: 'canceled';
165
+ /**
166
+ * An Error occurred, see TaskSnapshot.error for details.
167
+ */
168
+ ERROR: 'error';
169
+ /**
170
+ * Task has been paused. Resume the task via `StorageTask.resume()`.
171
+ */
172
+ PAUSED: 'paused';
173
+ /**
174
+ * Task is running. Pause the task via `StorageTask.pause()`
175
+ */
176
+ RUNNING: 'running';
177
+ /**
178
+ * Task has completed successfully.
179
+ */
180
+ SUCCESS: 'success';
181
+ }
182
+ /**
183
+ * Represents the current state of a running upload.
184
+ *
185
+ * Note: The Firebase JS SDK uses "canceled" (one L). React Native Firebase historically used "cancelled" (two L).
186
+ *
187
+ * @deprecated Use the exported types directly instead. FirebaseStorageTypes namespace is kept for backwards compatibility.
188
+ */
189
+ export type TaskStateType = 'running' | 'paused' | 'success' | 'canceled' | 'error';
190
+ /**
191
+ * Cloud Storage statics.
192
+ *
193
+ * @deprecated Use the exported types directly instead. FirebaseStorageTypes namespace is kept for backwards compatibility.
194
+ *
195
+ * #### Example
196
+ *
197
+ * ```js
198
+ * firebase.storage;
199
+ * ```
200
+ */
201
+ export interface Statics {
202
+ /**
203
+ * Possible string formats used for uploading via `StorageReference.putString()`
204
+ *
205
+ * #### Example
206
+ *
207
+ * ```js
208
+ * firebase.storage.StringFormat;
209
+ * ```
210
+ */
211
+ StringFormat: StringFormat;
212
+ /**
213
+ * A collection of properties that indicates the current tasks state.
214
+ *
215
+ * #### Example
216
+ *
217
+ * ```js
218
+ * firebase.storage.TaskState;
219
+ * ```
220
+ */
221
+ TaskState: TaskState;
222
+ /**
223
+ * An event to subscribe to that is triggered on a Upload or Download task.
224
+ *
225
+ * #### Example
226
+ *
227
+ * ```js
228
+ * firebase.storage.TaskEvent;
229
+ * ```
230
+ */
231
+ TaskEvent: TaskEventStatic;
232
+ SDK_VERSION: string;
233
+ }
234
+ /**
235
+ * Object metadata that can be set at any time.
236
+ *
237
+ * This is used in updateMetadata, put, putString & putFile.
238
+ *
239
+ * @deprecated Use the exported types directly instead. FirebaseStorageTypes namespace is kept for backwards compatibility.
240
+ */
241
+ export interface SettableMetadata {
242
+ /**
243
+ * The 'Cache-Control' HTTP header that will be set on the storage object when it's requested.
244
+ *
245
+ * #### Example 1
246
+ *
247
+ * To turn off caching, you can set the following cacheControl value.
248
+ *
249
+ * ```js
250
+ * {
251
+ * cacheControl: 'no-store',
252
+ * }
253
+ * ```
254
+ *
255
+ * #### Example 2
256
+ *
257
+ * To aggressively cache an object, e.g. static assets, you can set the following cacheControl value.
258
+ *
259
+ * ```js
260
+ * {
261
+ * cacheControl: 'public, max-age=31536000',
262
+ * }
263
+ * ```
264
+ *
265
+ * [Learn more about this header on Mozilla.](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cache-Control)
266
+ */
267
+ cacheControl?: string | undefined;
268
+ /**
269
+ * The 'Content-Disposition' HTTP header that will be set on the storage object when it's requested.
270
+ *
271
+ * [Learn more about this header on Mozilla.](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition)
272
+ */
273
+ contentDisposition?: string | undefined;
274
+ /**
275
+ * The 'Content-Encoding' HTTP header that will be used on the storage object when it's requested.
276
+ *
277
+ * [Learn more about this header on Mozilla.](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding)
278
+ */
279
+ contentEncoding?: string | undefined;
280
+ /**
281
+ * The 'Content-Language' HTTP header that will be set on the storage object when it's requested.
282
+ *
283
+ * [Learn more about this header on Mozilla.](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Language)
284
+ */
285
+ contentLanguage?: string | undefined;
286
+ /**
287
+ * The 'Content-Type' HTTP header that will be set on the object when it's requested.
288
+ *
289
+ * This is used to indicate the media type (or MIME type) of the object. When uploading a file
290
+ * Firebase Cloud Storage for React Native will attempt to automatically detect this if `contentType`
291
+ * is not already set, if it fails to detect a media type it will default to `application/octet-stream`.
292
+ *
293
+ * For `DATA_URL` string formats uploaded via `putString` this will also be automatically extracted if available.
294
+ *
295
+ * #### Example
296
+ *
297
+ * Setting the content type as JSON, e.g. for when uploading a JSON string via `putString`.
298
+ *
299
+ * ```js
300
+ * {
301
+ * contentType: 'application/json',
302
+ * }
303
+ * ```
304
+ *
305
+ * [Learn more about this header on Mozilla.](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type)
306
+ */
307
+ contentType?: string | undefined;
308
+ /**
309
+ * Additional user-defined custom metadata for this storage object.
310
+ *
311
+ * All values must be strings.
312
+ *
313
+ * #### Example
314
+ *
315
+ * Adding a user controlled NSFW meta data field.
316
+ *
317
+ * ```js
318
+ * {
319
+ * customMetadata: {
320
+ * 'nsfw': 'true'
321
+ * },
322
+ * }
323
+ */
324
+ customMetadata?: {
325
+ [key: string]: string;
326
+ } | undefined;
327
+ }
328
+ /**
329
+ * Object metadata that can be set at upload.
330
+ *
331
+ * @deprecated Use the exported types directly instead. FirebaseStorageTypes namespace is kept for backwards compatibility.
332
+ */
333
+ export interface UploadMetadata extends SettableMetadata {
334
+ /**
335
+ * A Base64-encoded MD5 hash of the object being uploaded.
336
+ */
337
+ md5Hash?: string | undefined;
338
+ }
339
+ /**
340
+ * The full readable metadata returned by `TaskSnapshot.metadata` or `StorageReference.getMetadata()`.
341
+ *
342
+ * @deprecated Use the exported types directly instead. FirebaseStorageTypes namespace is kept for backwards compatibility.
343
+ */
344
+ export interface FullMetadata extends UploadMetadata {
345
+ /**
346
+ * The bucket this storage object is contained in.
347
+ *
348
+ * #### Example Value
349
+ *
350
+ * ```
351
+ * gs://my-project-storage-bucket
352
+ * ```
353
+ */
354
+ bucket: string;
355
+ /**
356
+ * The full path to this storage object in its bucket.
357
+ *
358
+ * #### Example Value
359
+ *
360
+ * ```
361
+ * invertase/logo.png
362
+ * ```
363
+ */
364
+ fullPath: string;
365
+ /**
366
+ * Storage object generation values enable users to uniquely identify data resources, e.g. object versioning.
367
+ *
368
+ * Read more on generation on the [Google Cloud Storage documentation](https://cloud.google.com/storage/docs/generations-preconditions).
369
+ */
370
+ generation: string;
371
+ /**
372
+ * Storage object metageneration values enable users to uniquely identify data resources, e.g. object versioning.
373
+ *
374
+ * Read more on metageneration on the [Google Cloud Storage documentation](https://cloud.google.com/storage/docs/generations-preconditions).
375
+ */
376
+ metageneration: string;
377
+ /**
378
+ * The short name of storage object in its bucket, e.g. it's file name.
379
+ *
380
+ * #### Example Value
381
+ *
382
+ * ```
383
+ * logo.png
384
+ * ```
385
+ */
386
+ name: string;
387
+ /**
388
+ * The size of this storage object in bytes.
389
+ */
390
+ size: number;
391
+ /**
392
+ * A date string representing when this storage object was created.
393
+ *
394
+ * #### Example Value
395
+ *
396
+ * ```
397
+ * 2019-05-02T00:34:56.264Z
398
+ * ```
399
+ */
400
+ timeCreated: string;
401
+ /**
402
+ * A date string representing when this storage object was last updated.
403
+ *
404
+ * #### Example Value
405
+ *
406
+ * ```
407
+ * 2019-05-02T00:35:56.264Z
408
+ * ```
409
+ */
410
+ updated: string;
411
+ /**
412
+ * Tokens to allow access to the download URL.
413
+ */
414
+ downloadTokens: string[] | undefined;
415
+ /**
416
+ * `StorageReference` associated with this upload.
417
+ */
418
+ ref?: Reference | undefined;
419
+ }
420
+ /**
421
+ * Represents a reference to a Google Cloud Storage object in React Native Firebase.
422
+ *
423
+ * A reference can be used to upload and download storage objects, get/set storage object metadata, retrieve storage object download urls and delete storage objects.
424
+ *
425
+ * @deprecated Use the exported types directly instead. FirebaseStorageTypes namespace is kept for backwards compatibility.
426
+ *
427
+ * #### Example 1
428
+ *
429
+ * Get a reference to a specific storage path.
430
+ *
431
+ * ```js
432
+ * const ref = firebase.storage().ref('invertase/logo.png');
433
+ * ```
434
+ *
435
+ * #### Example 2
436
+ *
437
+ * Get a reference to a specific storage path on another bucket in the same firebase project.
438
+ *
439
+ * ```js
440
+ * const ref = firebase.storage().refFromURL('gs://other-bucket/invertase/logo.png');
441
+ * ```
442
+ */
443
+ export interface Reference {
444
+ /**
445
+ * The name of the bucket containing this reference's object.
446
+ */
447
+ bucket: string;
448
+ /**
449
+ * A reference pointing to the parent location of this reference, or null if this reference is the root.
450
+ */
451
+ parent: Reference | null;
452
+ /**
453
+ * The full path of this object.
454
+ */
455
+ fullPath: string;
456
+ /**
457
+ * The short name of this object, which is the last component of the full path. For example,
458
+ * if fullPath is 'full/path/image.png', name is 'image.png'.
459
+ */
460
+ name: string;
461
+ /**
462
+ * A reference to the root of this reference's bucket.
463
+ */
464
+ root: Reference;
465
+ /**
466
+ * The storage service associated with this reference.
467
+ */
468
+ storage: Module;
469
+ /**
470
+ * Returns a gs:// URL for this object in the form `gs://<bucket>/<path>/<to>/<object>`.
471
+ *
472
+ * #### Example
473
+ *
474
+ * ```js
475
+ * const ref = firebase.storage().ref('invertase/logo.png');
476
+ * console.log('Full path: ', ref.toString()); // gs://invertase.io/invertase/logo.png
477
+ * ```
478
+ */
479
+ toString(): string;
480
+ /**
481
+ * Returns a reference to a relative path from this reference.
482
+ *
483
+ * #### Example
484
+ *
485
+ * ```js
486
+ * const parent = firebase.storage().ref('invertase');
487
+ * const ref = parent.child('logo.png');
488
+ * ```
489
+ *
490
+ * @param path The relative path from this reference. Leading, trailing, and consecutive slashes are removed.
491
+ */
492
+ child(path: string): Reference;
493
+ /**
494
+ * Deletes the object at this reference's location.
495
+ *
496
+ * #### Example
497
+ *
498
+ * ```js
499
+ * const ref = firebase.storage().ref('invertase/logo.png');
500
+ * await ref.delete();
501
+ * ```
502
+ */
503
+ delete(): Promise<void>;
504
+ /**
505
+ * Fetches a long lived download URL for this object.
506
+ *
507
+ * #### Example
508
+ *
509
+ * ```js
510
+ * const ref = firebase.storage().ref('invertase/logo.png');
511
+ * const url = await ref.getDownloadURL();
512
+ * ```
513
+ */
514
+ getDownloadURL(): Promise<string>;
515
+ /**
516
+ * Fetches metadata for the object at this location, if one exists.
517
+ *
518
+ * #### Example
519
+ *
520
+ * ```js
521
+ * const ref = firebase.storage().ref('invertase/logo.png');
522
+ * const metadata = await ref.getMetadata();
523
+ * console.log('Cache control: ', metadata.cacheControl);
524
+ * ```
525
+ */
526
+ getMetadata(): Promise<FullMetadata>;
527
+ /**
528
+ * List items (files) and prefixes (folders) under this storage reference.
529
+ *
530
+ * List API is only available for Firebase Rules Version 2.
531
+ *
532
+ * GCS is a key-blob store. Firebase Storage imposes the semantic of '/' delimited folder structure.
533
+ * Refer to GCS's List API if you want to learn more.
534
+ *
535
+ * To adhere to Firebase Rules's Semantics, Firebase Storage does not support objects whose paths
536
+ * end with "/" or contain two consecutive "/"s. Firebase Storage List API will filter these unsupported objects.
537
+ * list() may fail if there are too many unsupported objects in the bucket.
538
+ *
539
+ * #### Example
540
+ *
541
+ * ```js
542
+ * const ref = firebase.storage().ref('/');
543
+ * const results = await ref.list({
544
+ * maxResults: 30,
545
+ * });
546
+ * ```
547
+ *
548
+ * @param options An optional ListOptions interface.
549
+ */
550
+ list(options?: ListOptions): Promise<ListResult>;
551
+ /**
552
+ * List all items (files) and prefixes (folders) under this storage reference.
553
+ *
554
+ * This is a helper method for calling list() repeatedly until there are no more results. The default pagination size is 1000.
555
+ *
556
+ * Note: The results may not be consistent if objects are changed while this operation is running.
557
+ *
558
+ * Warning: `listAll` may potentially consume too many resources if there are too many results.
559
+ *
560
+ * #### Example
561
+ *
562
+ * ```js
563
+ * const ref = firebase.storage().ref('/');
564
+ * const results = await ref.listAll();
565
+ * ```
566
+ */
567
+ listAll(): Promise<ListResult>;
568
+ /**
569
+ * Puts a file from local disk onto the storage bucket.
570
+ *
571
+ * #### Example
572
+ *
573
+ * ```js
574
+ * const ref = firebase.storage().ref('invertase/new-logo.png');
575
+ * const path = `${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/new-logo.png`;
576
+ * const task = ref.putFile(path, {
577
+ * cacheControl: 'no-store', // disable caching
578
+ * });
579
+ * ```
580
+ *
581
+ * @param localFilePath The local file path to upload to the bucket at the reference location.
582
+ * @param metadata Any additional `UploadMetadata` for this task.
583
+ */
584
+ putFile(localFilePath: string, metadata?: UploadMetadata): Task;
585
+ /**
586
+ * Downloads a file to the specified local file path on the device.
587
+ *
588
+ * #### Example
589
+ *
590
+ * Get a Download Storage task to download a file:
591
+ *
592
+ * ```js
593
+ * const downloadTo = `${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/foobar.json`;
594
+ *
595
+ * const task = firebase.storage().ref('/foo/bar.json').writeToFile(downloadTo);
596
+ * ```
597
+ * @param localFilePath
598
+ */
599
+ writeToFile(localFilePath: string): Task;
600
+ /**
601
+ * Puts data onto the storage bucket.
602
+ *
603
+ * #### Example
604
+ *
605
+ * ```js
606
+ * const ref = firebase.storage().ref('invertase/new-logo.png');
607
+ * const task = ref.put(BLOB, {
608
+ * cacheControl: 'no-store', // disable caching
609
+ * });
610
+ * ```
611
+ *
612
+ * @param data The data to upload to the storage bucket at the reference location.
613
+ * @param metadata
614
+ */
615
+ put(data: Blob | Uint8Array | ArrayBuffer, metadata?: UploadMetadata): Task;
616
+ /**
617
+ * Puts a string on the storage bucket. Depending on the string type, set a {@link StringFormat} type.
618
+ *
619
+ * #### Example
620
+ *
621
+ * ```js
622
+ * const ref = firebase.storage().ref('invertase/new-logo.png');
623
+ * const task = ref.putString('PEZvbyBCYXI+', firebase.storage.StringFormat.BASE64, {
624
+ * cacheControl: 'no-store', // disable caching
625
+ * });
626
+ * ```
627
+ *
628
+ * @param data The string data, must match the format provided.
629
+ * @param format The format type of the string, e.g. a Base64 format string.
630
+ * @param metadata Any additional `UploadMetadata` for this task.
631
+ */
632
+ putString(data: string, format?: 'raw' | 'base64' | 'base64url' | 'data_url', metadata?: UploadMetadata): Task;
633
+ /**
634
+ * Updates the metadata for this reference object on the storage bucket.
635
+ *
636
+ * #### Example
637
+ *
638
+ * ```js
639
+ * const ref = firebase.storage().ref('invertase/nsfw-logo.png');
640
+ * const updatedMetadata = await ref.updateMetadata({
641
+ * customMetadata: {
642
+ * 'nsfw': 'true',
643
+ * }
644
+ * });
645
+ * ```
646
+ *
647
+ * @param metadata A `SettableMetadata` instance to update.
648
+ */
649
+ updateMetadata(metadata: SettableMetadata): Promise<FullMetadata>;
650
+ }
651
+ /**
652
+ * The snapshot observer returned from a {@link Task#on} listener.
653
+ *
654
+ * #### Example
655
+ *
656
+ * @deprecated Use the exported types directly instead. FirebaseStorageTypes namespace is kept for backwards compatibility.
657
+ *
658
+ * ```js
659
+ * const ref = firebase.storage().ref(...);
660
+ * const task = ref.put(...)
661
+ *
662
+ * task.on('state_changed', {
663
+ * next(taskSnapshot) {
664
+ * console.log(taskSnapshot.state);
665
+ * },
666
+ * error(error) {
667
+ * console.error(error.message);
668
+ * },
669
+ * complete() {
670
+ * console.log('Task complete');
671
+ * },
672
+ * })
673
+ * ```
674
+ */
675
+ export interface TaskSnapshotObserver {
676
+ /**
677
+ * Called when the task state changes.
678
+ *
679
+ * @param taskSnapshot A `TaskSnapshot` for the event.
680
+ */
681
+ next?: (taskSnapshot: TaskSnapshot) => void;
682
+ /**
683
+ * Called when the task errors.
684
+ *
685
+ * @param error A JavaScript error.
686
+ */
687
+ error?: (error: NativeFirebaseError) => void;
688
+ /**
689
+ * Called when the task has completed successfully.
690
+ */
691
+ complete?: () => void;
692
+ }
693
+ /**
694
+ * Storage Task used for Uploading or Downloading files.
695
+ *
696
+ * #### Example 1
697
+ *
698
+ * @deprecated Use the exported types directly instead. FirebaseStorageTypes namespace is kept for backwards compatibility.
699
+ *
700
+ * Get a Upload Storage task to upload a string:
701
+ *
702
+ * ```js
703
+ * const string = '{ "foo": 1 }';
704
+ * const task = firebase
705
+ * .storage()
706
+ * .ref('/foo/bar.json')
707
+ * .putString(string);
708
+ * ```
709
+ *
710
+ * #### Example 2
711
+ *
712
+ * Get a Download Storage task to download a file:
713
+ *
714
+ * ```js
715
+ * const downloadTo = `${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/bar.json`;
716
+ *
717
+ * const task = firebase
718
+ * .storage()
719
+ * .ref('/foo/bar.json')
720
+ * .writeToFile(downloadTo);
721
+ * ```
722
+ */
723
+ export interface Task {
724
+ /**
725
+ * Initial state of Task.snapshot is `null`. Once uploading begins, it updates to a `TaskSnapshot` object.
726
+ */
727
+ snapshot: null | TaskSnapshot;
728
+ /**
729
+ * Pause the current Download or Upload task.
730
+ *
731
+ * #### Example
732
+ *
733
+ * Pause a running task inside a state changed listener:
734
+ *
735
+ * ```js
736
+ * task.on('state_changed', taskSnapshot => {
737
+ * if (taskSnapshot.state === firebase.storage.TaskState.RUNNING) {
738
+ * console.log('Pausing my task!');
739
+ * task.pause();
740
+ * }
741
+ * });
742
+ * ```
743
+ *
744
+ */
745
+ pause(): Promise<boolean>;
746
+ /**
747
+ * Resume the current Download or Upload task.
748
+ *
749
+ * #### Example
750
+ *
751
+ * Resume a previously paused task inside a state changed listener:
752
+ *
753
+ * ```js
754
+ * task.on('state_changed', taskSnapshot => {
755
+ * // ... pause me ...
756
+ * if (taskSnapshot.state === firebase.storage.TaskState.PAUSED) {
757
+ * console.log('Resuming my task!');
758
+ * task.resume();
759
+ * }
760
+ * });
761
+ * ```
762
+ *
763
+ */
764
+ resume(): Promise<boolean>;
765
+ /**
766
+ * Cancel the current Download or Upload task.
767
+ *
768
+ *
769
+ * #### Example
770
+ *
771
+ * Cancel a task inside a state changed listener:
772
+ *
773
+ * ```js
774
+ * task.on('state_changed', taskSnapshot => {
775
+ * console.log('Cancelling my task!');
776
+ * task.cancel();
777
+ * });
778
+ * ```
779
+ *
780
+ */
781
+ cancel(): Promise<boolean>;
782
+ /**
783
+ * Task event handler called when state has changed on the task.
784
+ *
785
+ * #### Example
786
+ *
787
+ * ```js
788
+ * const task = firebase
789
+ * .storage()
790
+ * .ref('/foo/bar.json')
791
+ * .writeToFile(downloadTo);
792
+ *
793
+ * task.on('state_changed', (taskSnapshot) => {
794
+ * console.log(taskSnapshot.state);
795
+ * });
796
+ *
797
+ * task.then(() => {]
798
+ * console.log('Task complete');
799
+ * })
800
+ * .catch((error) => {
801
+ * console.error(error.message);
802
+ * });
803
+ * ```
804
+ *
805
+ * @param event The event name to handle, always `state_changed`.
806
+ * @param nextOrObserver The optional event observer function.
807
+ * @param error An optional JavaScript error handler.
808
+ * @param complete An optional complete handler function.
809
+ */
810
+ on(event: 'state_changed', nextOrObserver?: TaskSnapshotObserver | null | ((a: TaskSnapshot) => any), error?: ((a: NativeFirebaseError) => any) | null, complete?: (() => void) | null): () => void;
811
+ then(onFulfilled?: ((a: TaskSnapshot) => any) | null, onRejected?: ((a: NativeFirebaseError) => any) | null): Promise<any>;
812
+ catch(onRejected: (a: NativeFirebaseError) => any): Promise<any>;
813
+ }
814
+ /**
815
+ * A TaskSnapshot provides information about a storage tasks state.
816
+ *
817
+ * #### Example 1
818
+ *
819
+ * @deprecated Use the exported types directly instead. FirebaseStorageTypes namespace is kept for backwards compatibility.
820
+ *
821
+ * ```js
822
+ * firebase
823
+ * .storage()
824
+ * .ref('/foo/bar.json')
825
+ * .putString(JSON.stringify({ foo: 'bar' }))
826
+ * .then((taskSnapshot) => {
827
+ * if (taskSnapshot.state === firebase.storage.TaskState.SUCCESS) {
828
+ * console.log('Total bytes uploaded: ', taskSnapshot.totalBytes);
829
+ * }
830
+ * });
831
+ * ```
832
+ *
833
+ * #### Example 2
834
+ *
835
+ * ```js
836
+ * const task = firebase
837
+ * .storage()
838
+ * .ref('/foo/bar.json')
839
+ * .putString(JSON.stringify({ foo: 'bar' }));
840
+ *
841
+ * task.on('state_changed', taskSnapshot => {
842
+ * if (taskSnapshot.state === firebase.storage.TaskState.PAUSED) {
843
+ * console.log('Resuming my task!');
844
+ * task.resume();
845
+ * }
846
+ * });
847
+ * ```
848
+ */
849
+ export interface TaskSnapshot {
850
+ /**
851
+ * The number of bytes currently transferred.
852
+ */
853
+ bytesTransferred: number;
854
+ /**
855
+ * The metadata of the tasks via a {@link FullMetadata} interface.
856
+ */
857
+ metadata: FullMetadata;
858
+ /**
859
+ * The {@link Reference} of the task.
860
+ */
861
+ ref: Reference;
862
+ /**
863
+ * The current state of the task snapshot.
864
+ */
865
+ state: TaskState;
866
+ /**
867
+ * The parent {@link Task} of this snapshot.
868
+ */
869
+ task: Task;
870
+ /**
871
+ * The total amount of bytes for this task.
872
+ */
873
+ totalBytes: number;
874
+ /**
875
+ * If the {@link TaskSnapshot#state} is `error`, returns a JavaScript error of the
876
+ * current task snapshot.
877
+ */
878
+ error?: NativeFirebaseError;
879
+ }
880
+ /**
881
+ * Result returned from a non-resumable upload.
882
+ *
883
+ * @deprecated Use the exported types directly instead. FirebaseStorageTypes namespace is kept for backwards compatibility.
884
+ */
885
+ export interface TaskResult {
886
+ /**
887
+ * The metadata of the tasks via a {@link FullMetadata} interface.
888
+ */
889
+ metadata: FullMetadata;
890
+ /**
891
+ * The {@link Reference} of the task.
892
+ */
893
+ ref: Reference;
894
+ }
895
+ /**
896
+ * The options `list()` accepts.
897
+ *
898
+ * @deprecated Use the exported types directly instead. FirebaseStorageTypes namespace is kept for backwards compatibility.
899
+ */
900
+ export interface ListOptions {
901
+ /**
902
+ * If set, limits the total number of `prefixes` and `items` to return. The default and maximum maxResults is 1000.
903
+ */
904
+ maxResults?: number;
905
+ /**
906
+ * The `nextPageToken` from a previous call to `list()`. If provided, listing is resumed from the previous position.
907
+ */
908
+ pageToken?: string | null;
909
+ }
910
+ /**
911
+ * Result returned by `list()`.
912
+ *
913
+ * @deprecated Use the exported types directly instead. FirebaseStorageTypes namespace is kept for backwards compatibility.
914
+ */
915
+ export interface ListResult {
916
+ /**
917
+ * Objects in this directory. You can call `getMetadata()` and `getDownloadUrl()` on them.
918
+ */
919
+ items: Reference[];
920
+ /**
921
+ * If set, there might be more results for this list. Use this token to resume the list.
922
+ */
923
+ nextPageToken: string | null;
924
+ /**
925
+ * References to prefixes (sub-folders). You can call `list()` on them to get its contents.
926
+ *
927
+ * Folders are implicit based on '/' in the object paths. For example, if a bucket has two objects '/a/b/1' and '/a/b/2', list('/a') will return '/a/b' as a prefix.
928
+ */
929
+ prefixes: Reference[];
930
+ }
931
+ /**
932
+ * Storage Emulator options. Web only.
933
+ *
934
+ * @deprecated Use the exported types directly instead. FirebaseStorageTypes namespace is kept for backwards compatibility.
935
+ */
936
+ export interface EmulatorMockTokenOptions {
937
+ /**
938
+ * the mock auth token to use for unit testing Security Rules.
939
+ */
940
+ mockUserToken?: string;
941
+ }
942
+ /**
943
+ * The Cloud Storage service is available for the default app, a given app or a specific storage bucket.
944
+ *
945
+ * #### Example 1
946
+ *
947
+ * @deprecated Use the exported types directly instead. FirebaseStorageTypes namespace is kept for backwards compatibility.
948
+ *
949
+ * Get the storage instance for the **default app**:
950
+ *
951
+ * ```js
952
+ * const storageForDefaultApp = firebase.storage();
953
+ * ```
954
+ *
955
+ * #### Example 2
956
+ *
957
+ * Get the storage instance for a **secondary app**:
958
+ *
959
+ * ```js
960
+ * const otherApp = firebase.app('otherApp');
961
+ * const storageForOtherApp = firebase.storage(otherApp);
962
+ * ```
963
+ *
964
+ * #### Example 3
965
+ *
966
+ * Get the storage instance for a **specific storage bucket**:
967
+ *
968
+ * ```js
969
+ * const defaultApp = firebase.app();
970
+ * const storageForBucket = defaultApp.storage('gs://another-bucket-url');
971
+ *
972
+ * const otherApp = firebase.app('otherApp');
973
+ * const storageForOtherAppBucket = otherApp.storage('gs://another-bucket-url');
974
+ * ```
975
+ *
976
+ */
977
+ export interface Module extends FirebaseModule {
978
+ /**
979
+ * The current `FirebaseApp` instance for this Firebase service.
980
+ */
981
+ app: ReactNativeFirebase.FirebaseApp;
982
+ /**
983
+ * Returns the current maximum time in milliseconds to retry an upload if a failure occurs.
984
+ *
985
+ * #### Example
986
+ *
987
+ * ```js
988
+ * const uploadRetryTime = firebase.storage().maxUploadRetryTime;
989
+ * ```
990
+ */
991
+ maxUploadRetryTime: number;
992
+ /**
993
+ * Sets the maximum time in milliseconds to retry an upload if a failure occurs.
994
+ *
995
+ * #### Example
996
+ *
997
+ * ```js
998
+ * await firebase.storage().setMaxUploadRetryTime(25000);
999
+ * ```
1000
+ *
1001
+ * @param time The new maximum upload retry time in milliseconds.
1002
+ */
1003
+ setMaxUploadRetryTime(time: number): Promise<void>;
1004
+ /**
1005
+ * Returns the current maximum time in milliseconds to retry a download if a failure occurs.
1006
+ *
1007
+ * #### Example
1008
+ *
1009
+ * ```js
1010
+ * const downloadRetryTime = firebase.storage().maxUploadRetryTime;
1011
+ * ```
1012
+ */
1013
+ maxDownloadRetryTime: number;
1014
+ /**
1015
+ * Sets the maximum time in milliseconds to retry a download if a failure occurs.
1016
+ *
1017
+ * #### Example
1018
+ *
1019
+ * ```js
1020
+ * await firebase.storage().setMaxDownloadRetryTime(25000);
1021
+ * ```
1022
+ *
1023
+ * @param time The new maximum download retry time in milliseconds.
1024
+ */
1025
+ setMaxDownloadRetryTime(time: number): Promise<void>;
1026
+ /**
1027
+ * Returns the current maximum time in milliseconds to retry operations other than upload and download if a failure occurs.
1028
+ *
1029
+ * #### Example
1030
+ *
1031
+ * ```js
1032
+ * const maxOperationRetryTime = firebase.storage().maxOperationRetryTime;
1033
+ * ```
1034
+ */
1035
+ maxOperationRetryTime: number;
1036
+ /**
1037
+ * Sets the maximum time in milliseconds to retry operations other than upload and download if a failure occurs.
1038
+ *
1039
+ * #### Example
1040
+ *
1041
+ * ```js
1042
+ * await firebase.storage().setMaxOperationRetryTime(5000);
1043
+ * ```
1044
+ *
1045
+ * @param time The new maximum operation retry time in milliseconds.
1046
+ */
1047
+ setMaxOperationRetryTime(time: number): Promise<void>;
1048
+ /**
1049
+ * Returns a new {@link Reference} instance.
1050
+ *
1051
+ * #### Example
1052
+ *
1053
+ * ```js
1054
+ * const ref = firebase.storage().ref('cats.gif');
1055
+ * ```
1056
+ *
1057
+ * @param path An optional string pointing to a location on the storage bucket. If no path
1058
+ * is provided, the returned reference will be the bucket root path.
1059
+ */
1060
+ ref(path?: string): Reference;
1061
+ /**
1062
+ * Returns a new {@link Reference} instance from a storage bucket URL.
1063
+ *
1064
+ * #### Example
1065
+ *
1066
+ * ```js
1067
+ * const gsUrl = 'gs://react-native-firebase-testing/cats.gif';
1068
+ * const httpUrl = 'https://firebasestorage.googleapis.com/v0/b/react-native-firebase-testing.appspot.com/o/cats.gif';
1069
+ *
1070
+ * const refFromGsUrl = firebase.storage().refFromURL(gsUrl);
1071
+ * // or
1072
+ * const refFromHttpUrl = firebase.storage().refFromURL(httpUrl);
1073
+ * ```
1074
+ *
1075
+ * @param url A storage bucket URL pointing to a single file or location. Must be either a `gs://` url or an `http` url,
1076
+ * e.g. `gs://assets/logo.png` or `https://firebasestorage.googleapis.com/v0/b/react-native-firebase-testing.appspot.com/o/cats.gif`.
1077
+ */
1078
+ refFromURL(url: string): Reference;
1079
+ /**
1080
+ * Modify this Storage instance to communicate with the Firebase Storage emulator.
1081
+ * This must be called synchronously immediately following the first call to firebase.storage().
1082
+ * Do not use with production credentials as emulator traffic is not encrypted.
1083
+ *
1084
+ * Note: on android, hosts 'localhost' and '127.0.0.1' are automatically remapped to '10.0.2.2' (the
1085
+ * "host" computer IP address for android emulators) to make the standard development experience easy.
1086
+ * If you want to use the emulator on a real android device, you will need to specify the actual host
1087
+ * computer IP address.
1088
+ *
1089
+ * @param host emulator host (eg, 'localhost')
1090
+ * @param port emulator port (eg, 9199)
1091
+ */
1092
+ useEmulator(host: string, port: number): void;
1093
+ }
1094
+ export {};
1095
+ }
1096
+ type StorageNamespace = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp<FirebaseStorageTypes.Module, FirebaseStorageTypes.Statics> & {
1097
+ firebase: ReactNativeFirebase.Module;
1098
+ app(name?: string): ReactNativeFirebase.FirebaseApp;
1099
+ };
1100
+ declare const defaultExport: StorageNamespace;
1101
+ export declare const firebase: ReactNativeFirebase.Module & {
1102
+ storage: typeof defaultExport;
1103
+ app(name?: string): ReactNativeFirebase.FirebaseApp & {
1104
+ storage(): FirebaseStorageTypes.Module;
1105
+ };
1106
+ };
1107
+ export default defaultExport;
1108
+ /**
1109
+ * Attach namespace to `firebase.` and `FirebaseApp.`.
1110
+ */
1111
+ declare module '@react-native-firebase/app' {
1112
+ namespace ReactNativeFirebase {
1113
+ import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp;
1114
+ interface Module {
1115
+ storage: FirebaseModuleWithStaticsAndApp<FirebaseStorageTypes.Module, FirebaseStorageTypes.Statics>;
1116
+ }
1117
+ interface FirebaseApp {
1118
+ storage(bucket?: string): FirebaseStorageTypes.Module;
1119
+ }
1120
+ }
1121
+ }
1122
+ //# sourceMappingURL=namespaced.d.ts.map