@depup/firebase__storage 0.14.1-depup.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 (101) hide show
  1. package/README.md +31 -0
  2. package/changes.json +10 -0
  3. package/dist/index.browser.cjs.js +3685 -0
  4. package/dist/index.browser.cjs.js.map +1 -0
  5. package/dist/index.cjs.js +3685 -0
  6. package/dist/index.cjs.js.map +1 -0
  7. package/dist/index.esm.js +3656 -0
  8. package/dist/index.esm.js.map +1 -0
  9. package/dist/index.node.cjs.js +3710 -0
  10. package/dist/index.node.cjs.js.map +1 -0
  11. package/dist/node-esm/index.node.esm.js +3681 -0
  12. package/dist/node-esm/index.node.esm.js.map +1 -0
  13. package/dist/node-esm/package.json +1 -0
  14. package/dist/node-esm/src/api.browser.d.ts +47 -0
  15. package/dist/node-esm/src/api.d.ts +200 -0
  16. package/dist/node-esm/src/api.node.d.ts +47 -0
  17. package/dist/node-esm/src/constants.d.ts +20 -0
  18. package/dist/node-esm/src/implementation/async.d.ts +22 -0
  19. package/dist/node-esm/src/implementation/backoff.d.ts +43 -0
  20. package/dist/node-esm/src/implementation/blob.d.ts +34 -0
  21. package/dist/node-esm/src/implementation/connection.d.ts +56 -0
  22. package/dist/node-esm/src/implementation/constants.d.ts +48 -0
  23. package/dist/node-esm/src/implementation/error.d.ts +126 -0
  24. package/dist/node-esm/src/implementation/failrequest.d.ts +29 -0
  25. package/dist/node-esm/src/implementation/fs.d.ts +17 -0
  26. package/dist/node-esm/src/implementation/json.d.ts +7 -0
  27. package/dist/node-esm/src/implementation/list.d.ts +19 -0
  28. package/dist/node-esm/src/implementation/location.d.ts +32 -0
  29. package/dist/node-esm/src/implementation/metadata.d.ts +40 -0
  30. package/dist/node-esm/src/implementation/observer.d.ts +47 -0
  31. package/dist/node-esm/src/implementation/path.d.ts +31 -0
  32. package/dist/node-esm/src/implementation/request.d.ts +47 -0
  33. package/dist/node-esm/src/implementation/requestinfo.d.ts +73 -0
  34. package/dist/node-esm/src/implementation/requests.d.ts +84 -0
  35. package/dist/node-esm/src/implementation/string.d.ts +73 -0
  36. package/dist/node-esm/src/implementation/taskenums.d.ts +77 -0
  37. package/dist/node-esm/src/implementation/type.d.ts +23 -0
  38. package/dist/node-esm/src/implementation/url.d.ts +22 -0
  39. package/dist/node-esm/src/implementation/utils.d.ts +23 -0
  40. package/dist/node-esm/src/index.d.ts +7 -0
  41. package/dist/node-esm/src/index.node.d.ts +7 -0
  42. package/dist/node-esm/src/list.d.ts +41 -0
  43. package/dist/node-esm/src/metadata.d.ts +27 -0
  44. package/dist/node-esm/src/platform/base64.d.ts +20 -0
  45. package/dist/node-esm/src/platform/browser/base64.d.ts +19 -0
  46. package/dist/node-esm/src/platform/browser/connection.d.ts +55 -0
  47. package/dist/node-esm/src/platform/connection.d.ts +22 -0
  48. package/dist/node-esm/src/platform/node/base64.d.ts +19 -0
  49. package/dist/node-esm/src/platform/node/connection.d.ts +58 -0
  50. package/dist/node-esm/src/public-types.d.ts +424 -0
  51. package/dist/node-esm/src/reference.d.ts +208 -0
  52. package/dist/node-esm/src/service.d.ts +131 -0
  53. package/dist/node-esm/src/task.d.ts +148 -0
  54. package/dist/node-esm/test/unit/connection.d.ts +47 -0
  55. package/dist/node-esm/test/unit/testshared.d.ts +60 -0
  56. package/dist/src/api.browser.d.ts +47 -0
  57. package/dist/src/api.d.ts +200 -0
  58. package/dist/src/api.node.d.ts +47 -0
  59. package/dist/src/constants.d.ts +20 -0
  60. package/dist/src/implementation/async.d.ts +22 -0
  61. package/dist/src/implementation/backoff.d.ts +43 -0
  62. package/dist/src/implementation/blob.d.ts +34 -0
  63. package/dist/src/implementation/connection.d.ts +56 -0
  64. package/dist/src/implementation/constants.d.ts +48 -0
  65. package/dist/src/implementation/error.d.ts +126 -0
  66. package/dist/src/implementation/failrequest.d.ts +29 -0
  67. package/dist/src/implementation/fs.d.ts +17 -0
  68. package/dist/src/implementation/json.d.ts +7 -0
  69. package/dist/src/implementation/list.d.ts +19 -0
  70. package/dist/src/implementation/location.d.ts +32 -0
  71. package/dist/src/implementation/metadata.d.ts +40 -0
  72. package/dist/src/implementation/observer.d.ts +47 -0
  73. package/dist/src/implementation/path.d.ts +31 -0
  74. package/dist/src/implementation/request.d.ts +47 -0
  75. package/dist/src/implementation/requestinfo.d.ts +73 -0
  76. package/dist/src/implementation/requests.d.ts +84 -0
  77. package/dist/src/implementation/string.d.ts +73 -0
  78. package/dist/src/implementation/taskenums.d.ts +77 -0
  79. package/dist/src/implementation/type.d.ts +23 -0
  80. package/dist/src/implementation/url.d.ts +22 -0
  81. package/dist/src/implementation/utils.d.ts +23 -0
  82. package/dist/src/index.d.ts +7 -0
  83. package/dist/src/index.node.d.ts +7 -0
  84. package/dist/src/list.d.ts +41 -0
  85. package/dist/src/metadata.d.ts +27 -0
  86. package/dist/src/platform/base64.d.ts +20 -0
  87. package/dist/src/platform/browser/base64.d.ts +19 -0
  88. package/dist/src/platform/browser/connection.d.ts +55 -0
  89. package/dist/src/platform/connection.d.ts +22 -0
  90. package/dist/src/platform/node/base64.d.ts +19 -0
  91. package/dist/src/platform/node/connection.d.ts +58 -0
  92. package/dist/src/public-types.d.ts +424 -0
  93. package/dist/src/reference.d.ts +208 -0
  94. package/dist/src/service.d.ts +131 -0
  95. package/dist/src/task.d.ts +148 -0
  96. package/dist/src/tsdoc-metadata.json +11 -0
  97. package/dist/storage-public.d.ts +725 -0
  98. package/dist/storage.d.ts +1391 -0
  99. package/dist/test/unit/connection.d.ts +47 -0
  100. package/dist/test/unit/testshared.d.ts +60 -0
  101. package/package.json +98 -0
@@ -0,0 +1,725 @@
1
+ /**
2
+ * Cloud Storage for Firebase
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import { CompleteFn , EmulatorMockTokenOptions , FirebaseError , NextFn , Subscribe , Unsubscribe } from '@firebase/util';
7
+ import { FirebaseApp } from '@firebase/app';
8
+ /**
9
+ * Modify this {@link FirebaseStorage} instance to communicate with the Cloud Storage emulator.
10
+ *
11
+ * @param storage - The {@link FirebaseStorage} instance
12
+ * @param host - The emulator host (ex: localhost)
13
+ * @param port - The emulator port (ex: 5001)
14
+ * @param options - Emulator options. `options.mockUserToken` is the mock auth
15
+ * token to use for unit testing Security Rules.
16
+ * @public
17
+ */
18
+ export declare function connectStorageEmulator(storage: FirebaseStorage, host: string, port: number, options?: {
19
+ mockUserToken?: EmulatorMockTokenOptions | string;
20
+ }): void;
21
+ /* Excluded from this release type: _dataFromString */
22
+ /**
23
+ * Deletes the object at this location.
24
+ * @public
25
+ * @param ref - {@link StorageReference} for object to delete.
26
+ * @returns A `Promise` that resolves if the deletion succeeds.
27
+ */
28
+ export declare function deleteObject(ref: StorageReference): Promise<void>;
29
+ export { EmulatorMockTokenOptions };
30
+ /* Excluded from this release type: _FbsBlob */
31
+ /* Excluded from this release type: _FirebaseService */
32
+ /**
33
+ * A Firebase Storage instance.
34
+ * @public
35
+ */
36
+ export declare interface FirebaseStorage {
37
+ /**
38
+ * The {@link @firebase/app#FirebaseApp} associated with this `FirebaseStorage` instance.
39
+ */
40
+ readonly app: FirebaseApp;
41
+ /**
42
+ * The maximum time to retry uploads in milliseconds.
43
+ */
44
+ maxUploadRetryTime: number;
45
+ /**
46
+ * The maximum time to retry operations other than uploads or downloads in
47
+ * milliseconds.
48
+ */
49
+ maxOperationRetryTime: number;
50
+ }
51
+ /* Excluded from this release type: _FirebaseStorageImpl */
52
+ /**
53
+ * The full set of object metadata, including read-only properties.
54
+ * @public
55
+ */
56
+ export declare interface FullMetadata extends UploadMetadata {
57
+ /**
58
+ * The bucket this object is contained in.
59
+ */
60
+ bucket: string;
61
+ /**
62
+ * The full path of this object.
63
+ */
64
+ fullPath: string;
65
+ /**
66
+ * The object's generation.
67
+ * {@link https://cloud.google.com/storage/docs/metadata#generation-number}
68
+ */
69
+ generation: string;
70
+ /**
71
+ * The object's metageneration.
72
+ * {@link https://cloud.google.com/storage/docs/metadata#generation-number}
73
+ */
74
+ metageneration: string;
75
+ /**
76
+ * The short name of this object, which is the last component of the full path.
77
+ * For example, if fullPath is 'full/path/image.png', name is 'image.png'.
78
+ */
79
+ name: string;
80
+ /**
81
+ * The size of this object, in bytes.
82
+ */
83
+ size: number;
84
+ /**
85
+ * A date string representing when this object was created.
86
+ */
87
+ timeCreated: string;
88
+ /**
89
+ * A date string representing when this object was last updated.
90
+ */
91
+ updated: string;
92
+ /**
93
+ * Tokens to allow access to the download URL.
94
+ */
95
+ downloadTokens: string[] | undefined;
96
+ /**
97
+ * `StorageReference` associated with this upload.
98
+ */
99
+ ref?: StorageReference | undefined;
100
+ }
101
+ /**
102
+ * Downloads the data at the object's location. Returns an error if the object
103
+ * is not found.
104
+ *
105
+ * To use this functionality, you have to whitelist your app's origin in your
106
+ * Cloud Storage bucket. See also
107
+ * https://cloud.google.com/storage/docs/configuring-cors
108
+ *
109
+ * This API is not available in Node.
110
+ *
111
+ * @public
112
+ * @param ref - StorageReference where data should be downloaded.
113
+ * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
114
+ * retrieve.
115
+ * @returns A Promise that resolves with a Blob containing the object's bytes
116
+ */
117
+ export declare function getBlob(ref: StorageReference, maxDownloadSizeBytes?: number): Promise<Blob>;
118
+ /**
119
+ * Downloads the data at the object's location. Returns an error if the object
120
+ * is not found.
121
+ *
122
+ * To use this functionality, you have to whitelist your app's origin in your
123
+ * Cloud Storage bucket. See also
124
+ * https://cloud.google.com/storage/docs/configuring-cors
125
+ *
126
+ * @public
127
+ * @param ref - StorageReference where data should be downloaded.
128
+ * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
129
+ * retrieve.
130
+ * @returns A Promise containing the object's bytes
131
+ */
132
+ export declare function getBytes(ref: StorageReference, maxDownloadSizeBytes?: number): Promise<ArrayBuffer>;
133
+ /* Excluded from this release type: _getChild */
134
+ /**
135
+ * Returns the download URL for the given {@link StorageReference}.
136
+ * @public
137
+ * @param ref - {@link StorageReference} to get the download URL for.
138
+ * @returns A `Promise` that resolves with the download
139
+ * URL for this object.
140
+ */
141
+ export declare function getDownloadURL(ref: StorageReference): Promise<string>;
142
+ /**
143
+ * A `Promise` that resolves with the metadata for this object. If this
144
+ * object doesn't exist or metadata cannot be retrieved, the promise is
145
+ * rejected.
146
+ * @public
147
+ * @param ref - {@link StorageReference} to get metadata from.
148
+ */
149
+ export declare function getMetadata(ref: StorageReference): Promise<FullMetadata>;
150
+ /**
151
+ * Gets a {@link FirebaseStorage} instance for the given Firebase app.
152
+ * @public
153
+ * @param app - Firebase app to get {@link FirebaseStorage} instance for.
154
+ * @param bucketUrl - The gs:// url to your Firebase Storage Bucket.
155
+ * If not passed, uses the app's default Storage Bucket.
156
+ * @returns A {@link FirebaseStorage} instance.
157
+ */
158
+ export declare function getStorage(app?: FirebaseApp, bucketUrl?: string): FirebaseStorage;
159
+ /**
160
+ * Downloads the data at the object's location. Raises an error event if the
161
+ * object is not found.
162
+ *
163
+ * This API is only available in Node.
164
+ *
165
+ * @public
166
+ * @param ref - StorageReference where data should be downloaded.
167
+ * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
168
+ * retrieve.
169
+ * @returns A stream with the object's data as bytes
170
+ */
171
+ export declare function getStream(ref: StorageReference, maxDownloadSizeBytes?: number): ReadableStream;
172
+ /* Excluded from this release type: _invalidArgument */
173
+ /* Excluded from this release type: _invalidRootOperation */
174
+ /**
175
+ * List items (files) and prefixes (folders) under this storage reference.
176
+ *
177
+ * List API is only available for Firebase Rules Version 2.
178
+ *
179
+ * GCS is a key-blob store. Firebase Storage imposes the semantic of '/'
180
+ * delimited folder structure.
181
+ * Refer to GCS's List API if you want to learn more.
182
+ *
183
+ * To adhere to Firebase Rules's Semantics, Firebase Storage does not
184
+ * support objects whose paths end with "/" or contain two consecutive
185
+ * "/"s. Firebase Storage List API will filter these unsupported objects.
186
+ * list() may fail if there are too many unsupported objects in the bucket.
187
+ * @public
188
+ *
189
+ * @param ref - {@link StorageReference} to get list from.
190
+ * @param options - See {@link ListOptions} for details.
191
+ * @returns A `Promise` that resolves with the items and prefixes.
192
+ * `prefixes` contains references to sub-folders and `items`
193
+ * contains references to objects in this folder. `nextPageToken`
194
+ * can be used to get the rest of the results.
195
+ */
196
+ export declare function list(ref: StorageReference, options?: ListOptions): Promise<ListResult>;
197
+ /**
198
+ * List all items (files) and prefixes (folders) under this storage reference.
199
+ *
200
+ * This is a helper method for calling list() repeatedly until there are
201
+ * no more results. The default pagination size is 1000.
202
+ *
203
+ * Note: The results may not be consistent if objects are changed while this
204
+ * operation is running.
205
+ *
206
+ * Warning: `listAll` may potentially consume too many resources if there are
207
+ * too many results.
208
+ * @public
209
+ * @param ref - {@link StorageReference} to get list from.
210
+ *
211
+ * @returns A `Promise` that resolves with all the items and prefixes under
212
+ * the current storage reference. `prefixes` contains references to
213
+ * sub-directories and `items` contains references to objects in this
214
+ * folder. `nextPageToken` is never returned.
215
+ */
216
+ export declare function listAll(ref: StorageReference): Promise<ListResult>;
217
+ /**
218
+ * The options `list()` accepts.
219
+ * @public
220
+ */
221
+ export declare interface ListOptions {
222
+ /**
223
+ * If set, limits the total number of `prefixes` and `items` to return.
224
+ * The default and maximum maxResults is 1000.
225
+ */
226
+ maxResults?: number | null;
227
+ /**
228
+ * The `nextPageToken` from a previous call to `list()`. If provided,
229
+ * listing is resumed from the previous position.
230
+ */
231
+ pageToken?: string | null;
232
+ }
233
+ /**
234
+ * Result returned by list().
235
+ * @public
236
+ */
237
+ export declare interface ListResult {
238
+ /**
239
+ * References to prefixes (sub-folders). You can call list() on them to
240
+ * get its contents.
241
+ *
242
+ * Folders are implicit based on '/' in the object paths.
243
+ * For example, if a bucket has two objects '/a/b/1' and '/a/b/2', list('/a')
244
+ * will return '/a/b' as a prefix.
245
+ */
246
+ prefixes: StorageReference[];
247
+ /**
248
+ * Objects in this directory.
249
+ * You can call getMetadata() and getDownloadUrl() on them.
250
+ */
251
+ items: StorageReference[];
252
+ /**
253
+ * If set, there might be more results for this list. Use this token to resume the list.
254
+ */
255
+ nextPageToken?: string;
256
+ }
257
+ /**
258
+ * Returns a {@link StorageReference} for the given url.
259
+ * @param storage - {@link FirebaseStorage} instance.
260
+ * @param url - URL. If empty, returns root reference.
261
+ * @public
262
+ */
263
+ export declare function ref(storage: FirebaseStorage, url?: string): StorageReference;
264
+ /**
265
+ * Returns a {@link StorageReference} for the given path in the
266
+ * default bucket.
267
+ * @param storageOrRef - {@link FirebaseStorage} or {@link StorageReference}.
268
+ * @param pathOrUrlStorage - path. If empty, returns root reference (if {@link FirebaseStorage}
269
+ * instance provided) or returns same reference (if {@link StorageReference} provided).
270
+ * @public
271
+ */
272
+ export declare function ref(storageOrRef: FirebaseStorage | StorageReference, path?: string): StorageReference;
273
+ /**
274
+ * Object metadata that can be set at any time.
275
+ * @public
276
+ */
277
+ export declare interface SettableMetadata {
278
+ /**
279
+ * Served as the 'Cache-Control' header on object download.
280
+ */
281
+ cacheControl?: string | undefined;
282
+ /**
283
+ * Served as the 'Content-Disposition' header on object download.
284
+ */
285
+ contentDisposition?: string | undefined;
286
+ /**
287
+ * Served as the 'Content-Encoding' header on object download.
288
+ */
289
+ contentEncoding?: string | undefined;
290
+ /**
291
+ * Served as the 'Content-Language' header on object download.
292
+ */
293
+ contentLanguage?: string | undefined;
294
+ /**
295
+ * Served as the 'Content-Type' header on object download.
296
+ */
297
+ contentType?: string | undefined;
298
+ /**
299
+ * Additional user-defined custom metadata.
300
+ */
301
+ customMetadata?: {
302
+ [key: string]: string;
303
+ } | undefined;
304
+ }
305
+ /**
306
+ * An error returned by the Firebase Storage SDK.
307
+ * @public
308
+ */
309
+ export declare class StorageError extends FirebaseError {
310
+ private status_;
311
+ /**
312
+ * Stores custom error data unique to the `StorageError`.
313
+ */
314
+ customData: {
315
+ serverResponse: string | null;
316
+ };
317
+ /**
318
+ * @param code - A `StorageErrorCode` string to be prefixed with 'storage/' and
319
+ * added to the end of the message.
320
+ * @param message - Error message.
321
+ * @param status_ - Corresponding HTTP Status Code
322
+ */
323
+ constructor(code: StorageErrorCode, message: string, status_?: number);
324
+ get status(): number;
325
+ set status(status: number);
326
+ /**
327
+ * Optional response message that was added by the server.
328
+ */
329
+ get serverResponse(): null | string;
330
+ set serverResponse(serverResponse: string | null);
331
+ }
332
+ /**
333
+ * @public
334
+ * Error codes that can be attached to `StorageError` objects.
335
+ */
336
+ export declare enum StorageErrorCode {
337
+ UNKNOWN = "unknown",
338
+ OBJECT_NOT_FOUND = "object-not-found",
339
+ BUCKET_NOT_FOUND = "bucket-not-found",
340
+ PROJECT_NOT_FOUND = "project-not-found",
341
+ QUOTA_EXCEEDED = "quota-exceeded",
342
+ UNAUTHENTICATED = "unauthenticated",
343
+ UNAUTHORIZED = "unauthorized",
344
+ UNAUTHORIZED_APP = "unauthorized-app",
345
+ RETRY_LIMIT_EXCEEDED = "retry-limit-exceeded",
346
+ INVALID_CHECKSUM = "invalid-checksum",
347
+ CANCELED = "canceled",
348
+ INVALID_EVENT_NAME = "invalid-event-name",
349
+ INVALID_URL = "invalid-url",
350
+ INVALID_DEFAULT_BUCKET = "invalid-default-bucket",
351
+ NO_DEFAULT_BUCKET = "no-default-bucket",
352
+ CANNOT_SLICE_BLOB = "cannot-slice-blob",
353
+ SERVER_FILE_WRONG_SIZE = "server-file-wrong-size",
354
+ NO_DOWNLOAD_URL = "no-download-url",
355
+ INVALID_ARGUMENT = "invalid-argument",
356
+ INVALID_ARGUMENT_COUNT = "invalid-argument-count",
357
+ APP_DELETED = "app-deleted",
358
+ INVALID_ROOT_OPERATION = "invalid-root-operation",
359
+ INVALID_FORMAT = "invalid-format",
360
+ INTERNAL_ERROR = "internal-error",
361
+ UNSUPPORTED_ENVIRONMENT = "unsupported-environment"
362
+ }
363
+ /**
364
+ * A stream observer for Firebase Storage.
365
+ * @public
366
+ */
367
+ export declare interface StorageObserver<T> {
368
+ next?: NextFn<T> | null;
369
+ error?: (error: StorageError) => void | null;
370
+ complete?: CompleteFn | null;
371
+ }
372
+ /**
373
+ * Represents a reference to a Google Cloud Storage object. Developers can
374
+ * upload, download, and delete objects, as well as get/set object metadata.
375
+ * @public
376
+ */
377
+ export declare interface StorageReference {
378
+ /**
379
+ * Returns a gs:// URL for this object in the form
380
+ * `gs://<bucket>/<path>/<to>/<object>`
381
+ * @returns The gs:// URL.
382
+ */
383
+ toString(): string;
384
+ /**
385
+ * A reference to the root of this object's bucket.
386
+ */
387
+ root: StorageReference;
388
+ /**
389
+ * The name of the bucket containing this reference's object.
390
+ */
391
+ bucket: string;
392
+ /**
393
+ * The full path of this object.
394
+ */
395
+ fullPath: string;
396
+ /**
397
+ * The short name of this object, which is the last component of the full path.
398
+ * For example, if fullPath is 'full/path/image.png', name is 'image.png'.
399
+ */
400
+ name: string;
401
+ /**
402
+ * The {@link FirebaseStorage} instance associated with this reference.
403
+ */
404
+ storage: FirebaseStorage;
405
+ /**
406
+ * A reference pointing to the parent location of this reference, or null if
407
+ * this reference is the root.
408
+ */
409
+ parent: StorageReference | null;
410
+ }
411
+ /**
412
+ * @license
413
+ * Copyright 2017 Google LLC
414
+ *
415
+ * Licensed under the Apache License, Version 2.0 (the "License");
416
+ * you may not use this file except in compliance with the License.
417
+ * You may obtain a copy of the License at
418
+ *
419
+ * http://www.apache.org/licenses/LICENSE-2.0
420
+ *
421
+ * Unless required by applicable law or agreed to in writing, software
422
+ * distributed under the License is distributed on an "AS IS" BASIS,
423
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
424
+ * See the License for the specific language governing permissions and
425
+ * limitations under the License.
426
+ */
427
+ /**
428
+ * An enumeration of the possible string formats for upload.
429
+ * @public
430
+ */
431
+ export declare type StringFormat = (typeof StringFormat)[keyof typeof StringFormat];
432
+ /**
433
+ * An enumeration of the possible string formats for upload.
434
+ * @public
435
+ */
436
+ export declare const StringFormat: {
437
+ /**
438
+ * Indicates the string should be interpreted "raw", that is, as normal text.
439
+ * The string will be interpreted as UTF-16, then uploaded as a UTF-8 byte
440
+ * sequence.
441
+ * Example: The string 'Hello! \\ud83d\\ude0a' becomes the byte sequence
442
+ * 48 65 6c 6c 6f 21 20 f0 9f 98 8a
443
+ */
444
+ readonly RAW: "raw";
445
+ /**
446
+ * Indicates the string should be interpreted as base64-encoded data.
447
+ * Padding characters (trailing '='s) are optional.
448
+ * Example: The string 'rWmO++E6t7/rlw==' becomes the byte sequence
449
+ * ad 69 8e fb e1 3a b7 bf eb 97
450
+ */
451
+ readonly BASE64: "base64";
452
+ /**
453
+ * Indicates the string should be interpreted as base64url-encoded data.
454
+ * Padding characters (trailing '='s) are optional.
455
+ * Example: The string 'rWmO--E6t7_rlw==' becomes the byte sequence
456
+ * ad 69 8e fb e1 3a b7 bf eb 97
457
+ */
458
+ readonly BASE64URL: "base64url";
459
+ /**
460
+ * Indicates the string is a data URL, such as one obtained from
461
+ * canvas.toDataURL().
462
+ * Example: the string 'data:application/octet-stream;base64,aaaa'
463
+ * becomes the byte sequence
464
+ * 69 a6 9a
465
+ * (the content-type "application/octet-stream" is also applied, but can
466
+ * be overridden in the metadata object).
467
+ */
468
+ readonly DATA_URL: "data_url";
469
+ };
470
+ /**
471
+ * An event that is triggered on a task.
472
+ * @public
473
+ */
474
+ export declare type TaskEvent = 'state_changed';
475
+ /* Excluded from this release type: _TaskEvent */
476
+ /**
477
+ * Represents the current state of a running upload.
478
+ * @public
479
+ */
480
+ export declare type TaskState = 'running' | 'paused' | 'success' | 'canceled' | 'error';
481
+ /**
482
+ * Updates the metadata for this object.
483
+ * @public
484
+ * @param ref - {@link StorageReference} to update metadata for.
485
+ * @param metadata - The new metadata for the object.
486
+ * Only values that have been explicitly set will be changed. Explicitly
487
+ * setting a value to null will remove the metadata.
488
+ * @returns A `Promise` that resolves with the new metadata for this object.
489
+ */
490
+ export declare function updateMetadata(ref: StorageReference, metadata: SettableMetadata): Promise<FullMetadata>;
491
+ /**
492
+ * Uploads data to this object's location.
493
+ * The upload is not resumable.
494
+ * @public
495
+ * @param ref - {@link StorageReference} where data should be uploaded.
496
+ * @param data - The data to upload.
497
+ * @param metadata - Metadata for the data to upload.
498
+ * @returns A Promise containing an UploadResult
499
+ */
500
+ export declare function uploadBytes(ref: StorageReference, data: Blob | Uint8Array | ArrayBuffer, metadata?: UploadMetadata): Promise<UploadResult>;
501
+ /**
502
+ * Uploads data to this object's location.
503
+ * The upload can be paused and resumed, and exposes progress updates.
504
+ * @public
505
+ * @param ref - {@link StorageReference} where data should be uploaded.
506
+ * @param data - The data to upload.
507
+ * @param metadata - Metadata for the data to upload.
508
+ * @returns An UploadTask
509
+ */
510
+ export declare function uploadBytesResumable(ref: StorageReference, data: Blob | Uint8Array | ArrayBuffer, metadata?: UploadMetadata): UploadTask;
511
+ /**
512
+ * Object metadata that can be set at upload.
513
+ * @public
514
+ */
515
+ export declare interface UploadMetadata extends SettableMetadata {
516
+ /**
517
+ * A Base64-encoded MD5 hash of the object being uploaded.
518
+ */
519
+ md5Hash?: string | undefined;
520
+ }
521
+ /**
522
+ * Result returned from a non-resumable upload.
523
+ * @public
524
+ */
525
+ export declare interface UploadResult {
526
+ /**
527
+ * Contains the metadata sent back from the server.
528
+ */
529
+ readonly metadata: FullMetadata;
530
+ /**
531
+ * The reference that spawned this upload.
532
+ */
533
+ readonly ref: StorageReference;
534
+ }
535
+ /**
536
+ * Uploads a string to this object's location.
537
+ * The upload is not resumable.
538
+ * @public
539
+ * @param ref - {@link StorageReference} where string should be uploaded.
540
+ * @param value - The string to upload.
541
+ * @param format - The format of the string to upload.
542
+ * @param metadata - Metadata for the string to upload.
543
+ * @returns A Promise containing an UploadResult
544
+ */
545
+ export declare function uploadString(ref: StorageReference, value: string, format?: StringFormat, metadata?: UploadMetadata): Promise<UploadResult>;
546
+ /**
547
+ * Represents the process of uploading an object. Allows you to monitor and
548
+ * manage the upload.
549
+ * @public
550
+ */
551
+ export declare interface UploadTask {
552
+ /**
553
+ * Cancels a running task. Has no effect on a complete or failed task.
554
+ * @returns True if the cancel had an effect.
555
+ */
556
+ cancel(): boolean;
557
+ /**
558
+ * Equivalent to calling `then(null, onRejected)`.
559
+ */
560
+ catch(onRejected: (error: StorageError) => unknown): Promise<unknown>;
561
+ /**
562
+ * Listens for events on this task.
563
+ *
564
+ * Events have three callback functions (referred to as `next`, `error`, and
565
+ * `complete`).
566
+ *
567
+ * If only the event is passed, a function that can be used to register the
568
+ * callbacks is returned. Otherwise, the callbacks are passed after the event.
569
+ *
570
+ * Callbacks can be passed either as three separate arguments <em>or</em> as the
571
+ * `next`, `error`, and `complete` properties of an object. Any of the three
572
+ * callbacks is optional, as long as at least one is specified. In addition,
573
+ * when you add your callbacks, you get a function back. You can call this
574
+ * function to unregister the associated callbacks.
575
+ *
576
+ * @example **Pass callbacks separately or in an object.**
577
+ * ```javascript
578
+ * var next = function(snapshot) {};
579
+ * var error = function(error) {};
580
+ * var complete = function() {};
581
+ *
582
+ * // The first example.
583
+ * uploadTask.on(
584
+ * firebase.storage.TaskEvent.STATE_CHANGED,
585
+ * next,
586
+ * error,
587
+ * complete);
588
+ *
589
+ * // This is equivalent to the first example.
590
+ * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, {
591
+ * 'next': next,
592
+ * 'error': error,
593
+ * 'complete': complete
594
+ * });
595
+ *
596
+ * // This is equivalent to the first example.
597
+ * var subscribe = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED);
598
+ * subscribe(next, error, complete);
599
+ *
600
+ * // This is equivalent to the first example.
601
+ * var subscribe = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED);
602
+ * subscribe({
603
+ * 'next': next,
604
+ * 'error': error,
605
+ * 'complete': complete
606
+ * });
607
+ * ```
608
+ *
609
+ * @example **Any callback is optional.**
610
+ * ```javascript
611
+ * // Just listening for completion, this is legal.
612
+ * uploadTask.on(
613
+ * firebase.storage.TaskEvent.STATE_CHANGED,
614
+ * null,
615
+ * null,
616
+ * function() {
617
+ * console.log('upload complete!');
618
+ * });
619
+ *
620
+ * // Just listening for progress/state changes, this is legal.
621
+ * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, function(snapshot) {
622
+ * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100;
623
+ * console.log(percent + "% done");
624
+ * });
625
+ *
626
+ * // This is also legal.
627
+ * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, {
628
+ * 'complete': function() {
629
+ * console.log('upload complete!');
630
+ * }
631
+ * });
632
+ * ```
633
+ *
634
+ * @example **Use the returned function to remove callbacks.**
635
+ * ```javascript
636
+ * var unsubscribe = uploadTask.on(
637
+ * firebase.storage.TaskEvent.STATE_CHANGED,
638
+ * function(snapshot) {
639
+ * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100;
640
+ * console.log(percent + "% done");
641
+ * // Stop after receiving one update.
642
+ * unsubscribe();
643
+ * });
644
+ *
645
+ * // This code is equivalent to the above.
646
+ * var handle = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED);
647
+ * unsubscribe = handle(function(snapshot) {
648
+ * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100;
649
+ * console.log(percent + "% done");
650
+ * // Stop after receiving one update.
651
+ * unsubscribe();
652
+ * });
653
+ * ```
654
+ *
655
+ * @param event - The type of event to listen for.
656
+ * @param nextOrObserver -
657
+ * The `next` function, which gets called for each item in
658
+ * the event stream, or an observer object with some or all of these three
659
+ * properties (`next`, `error`, `complete`).
660
+ * @param error - A function that gets called with a `StorageError`
661
+ * if the event stream ends due to an error.
662
+ * @param completed - A function that gets called if the
663
+ * event stream ends normally.
664
+ * @returns
665
+ * If only the event argument is passed, returns a function you can use to
666
+ * add callbacks (see the examples above). If more than just the event
667
+ * argument is passed, returns a function you can call to unregister the
668
+ * callbacks.
669
+ */
670
+ on(event: TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError) => unknown) | null, complete?: Unsubscribe | null): Unsubscribe | Subscribe<UploadTaskSnapshot>;
671
+ /**
672
+ * Pauses a currently running task. Has no effect on a paused or failed task.
673
+ * @returns True if the operation took effect, false if ignored.
674
+ */
675
+ pause(): boolean;
676
+ /**
677
+ * Resumes a paused task. Has no effect on a currently running or failed task.
678
+ * @returns True if the operation took effect, false if ignored.
679
+ */
680
+ resume(): boolean;
681
+ /**
682
+ * A snapshot of the current task state.
683
+ */
684
+ snapshot: UploadTaskSnapshot;
685
+ /**
686
+ * This object behaves like a Promise, and resolves with its snapshot data
687
+ * when the upload completes.
688
+ * @param onFulfilled - The fulfillment callback. Promise chaining works as normal.
689
+ * @param onRejected - The rejection callback.
690
+ */
691
+ then(onFulfilled?: ((snapshot: UploadTaskSnapshot) => unknown) | null, onRejected?: ((error: StorageError) => unknown) | null): Promise<unknown>;
692
+ }
693
+ /* Excluded from this release type: _UploadTask */
694
+ /**
695
+ * Holds data about the current state of the upload task.
696
+ * @public
697
+ */
698
+ export declare interface UploadTaskSnapshot {
699
+ /**
700
+ * The number of bytes that have been successfully uploaded so far.
701
+ */
702
+ bytesTransferred: number;
703
+ /**
704
+ * Before the upload completes, contains the metadata sent to the server.
705
+ * After the upload completes, contains the metadata sent back from the server.
706
+ */
707
+ metadata: FullMetadata;
708
+ /**
709
+ * The reference that spawned this snapshot's upload task.
710
+ */
711
+ ref: StorageReference;
712
+ /**
713
+ * The current state of the task.
714
+ */
715
+ state: TaskState;
716
+ /**
717
+ * The task of which this is a snapshot.
718
+ */
719
+ task: UploadTask;
720
+ /**
721
+ * The total number of bytes to be uploaded.
722
+ */
723
+ totalBytes: number;
724
+ }
725
+ export {};