@firebase/storage 0.8.4-canary.4594d3fd6 → 0.8.4-pr5646.1ea90dcb0

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 (63) hide show
  1. package/dist/index.browser.cjs.js +1 -1
  2. package/dist/index.esm2017.js +1 -1
  3. package/dist/index.esm5.js +1 -1
  4. package/dist/{index.cjs.js → index.node.cjs.js} +2 -2
  5. package/dist/index.node.cjs.js.map +1 -0
  6. package/dist/node-esm/index.node.esm.js +3351 -0
  7. package/dist/node-esm/index.node.esm.js.map +1 -0
  8. package/dist/node-esm/package.json +1 -0
  9. package/dist/node-esm/src/api.browser.d.ts +17 -0
  10. package/dist/node-esm/src/api.d.ts +184 -0
  11. package/dist/node-esm/src/api.node.d.ts +17 -0
  12. package/dist/node-esm/src/constants.d.ts +20 -0
  13. package/dist/node-esm/src/implementation/async.d.ts +22 -0
  14. package/dist/node-esm/src/implementation/backoff.d.ts +37 -0
  15. package/dist/node-esm/src/implementation/blob.d.ts +34 -0
  16. package/dist/node-esm/src/implementation/connection.d.ts +47 -0
  17. package/dist/node-esm/src/implementation/constants.d.ts +44 -0
  18. package/dist/node-esm/src/implementation/error.d.ts +105 -0
  19. package/dist/node-esm/src/implementation/failrequest.d.ts +29 -0
  20. package/dist/node-esm/src/implementation/fs.d.ts +17 -0
  21. package/dist/node-esm/src/implementation/json.d.ts +7 -0
  22. package/dist/node-esm/src/implementation/list.d.ts +19 -0
  23. package/dist/node-esm/src/implementation/location.d.ts +32 -0
  24. package/dist/node-esm/src/implementation/metadata.d.ts +40 -0
  25. package/dist/node-esm/src/implementation/observer.d.ts +47 -0
  26. package/dist/node-esm/src/implementation/path.d.ts +31 -0
  27. package/dist/node-esm/src/implementation/request.d.ts +47 -0
  28. package/dist/node-esm/src/implementation/requestinfo.d.ts +65 -0
  29. package/dist/node-esm/src/implementation/requests.d.ts +83 -0
  30. package/dist/node-esm/src/implementation/string.d.ts +73 -0
  31. package/dist/node-esm/src/implementation/taskenums.d.ts +77 -0
  32. package/dist/node-esm/src/implementation/type.d.ts +23 -0
  33. package/dist/node-esm/src/implementation/url.d.ts +22 -0
  34. package/dist/node-esm/src/index.d.ts +7 -0
  35. package/dist/node-esm/src/index.node.d.ts +7 -0
  36. package/dist/node-esm/src/list.d.ts +41 -0
  37. package/dist/node-esm/src/metadata.d.ts +27 -0
  38. package/dist/node-esm/src/platform/base64.d.ts +20 -0
  39. package/dist/node-esm/src/platform/browser/base64.d.ts +19 -0
  40. package/dist/node-esm/src/platform/browser/connection.d.ts +39 -0
  41. package/dist/node-esm/src/platform/connection.d.ts +19 -0
  42. package/dist/node-esm/src/platform/node/base64.d.ts +19 -0
  43. package/dist/node-esm/src/platform/node/connection.d.ts +45 -0
  44. package/dist/node-esm/src/public-types.d.ts +433 -0
  45. package/dist/node-esm/src/reference.d.ts +196 -0
  46. package/dist/node-esm/src/service.d.ts +130 -0
  47. package/dist/node-esm/src/task.d.ts +143 -0
  48. package/dist/node-esm/test/browser/blob.test.d.ts +17 -0
  49. package/dist/node-esm/test/browser/connection.test.d.ts +17 -0
  50. package/dist/node-esm/test/integration/integration.test.d.ts +20 -0
  51. package/dist/node-esm/test/unit/connection.d.ts +46 -0
  52. package/dist/node-esm/test/unit/connection.test.d.ts +17 -0
  53. package/dist/node-esm/test/unit/index.test.d.ts +4 -0
  54. package/dist/node-esm/test/unit/location.test.d.ts +1 -0
  55. package/dist/node-esm/test/unit/reference.test.d.ts +1 -0
  56. package/dist/node-esm/test/unit/request.test.d.ts +1 -0
  57. package/dist/node-esm/test/unit/requests.test.d.ts +1 -0
  58. package/dist/node-esm/test/unit/service.test.d.ts +1 -0
  59. package/dist/node-esm/test/unit/string.test.d.ts +1 -0
  60. package/dist/node-esm/test/unit/task.test.d.ts +1 -0
  61. package/dist/node-esm/test/unit/testshared.d.ts +47 -0
  62. package/package.json +17 -7
  63. package/dist/index.cjs.js.map +0 -1
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2021 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /** Converts a Base64 encoded string to a binary string. */
18
+ export declare function decodeBase64(encoded: string): string;
19
+ export declare function decodeUint8Array(data: Uint8Array): string;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2021 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { ErrorCode, Connection } from '../../implementation/connection';
18
+ /**
19
+ * Network layer that works in Node.
20
+ *
21
+ * This network implementation should not be used in browsers as it does not
22
+ * support progress updates.
23
+ */
24
+ export declare class FetchConnection implements Connection {
25
+ private errorCode_;
26
+ private statusCode_;
27
+ private body_;
28
+ private headers_;
29
+ private sent_;
30
+ private fetch_;
31
+ constructor();
32
+ send(url: string, method: string, body?: ArrayBufferView | Blob | string, headers?: Record<string, string>): Promise<void>;
33
+ getErrorCode(): ErrorCode;
34
+ getStatus(): number;
35
+ getResponseText(): string;
36
+ abort(): void;
37
+ getResponseHeader(header: string): string | null;
38
+ addUploadProgressListener(listener: (p1: ProgressEvent) => void): void;
39
+ /**
40
+ * @override
41
+ */
42
+ removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void;
43
+ }
44
+ export declare function newConnection(): Connection;
45
+ export declare function injectTestConnection(factory: (() => Connection) | null): void;
@@ -0,0 +1,433 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { FirebaseApp, _FirebaseService } from '@firebase/app';
18
+ import { CompleteFn, FirebaseError, NextFn, Subscribe, Unsubscribe } from '@firebase/util';
19
+ /**
20
+ * A Firebase Storage instance.
21
+ * @public
22
+ */
23
+ export interface FirebaseStorage extends _FirebaseService {
24
+ /**
25
+ * The {@link @firebase/app#FirebaseApp} associated with this `FirebaseStorage` instance.
26
+ */
27
+ readonly app: FirebaseApp;
28
+ /**
29
+ * The maximum time to retry uploads in milliseconds.
30
+ */
31
+ maxUploadRetryTime: number;
32
+ /**
33
+ * The maximum time to retry operations other than uploads or downloads in
34
+ * milliseconds.
35
+ */
36
+ maxOperationRetryTime: number;
37
+ }
38
+ /**
39
+ * Represents a reference to a Google Cloud Storage object. Developers can
40
+ * upload, download, and delete objects, as well as get/set object metadata.
41
+ * @public
42
+ */
43
+ export interface StorageReference {
44
+ /**
45
+ * Returns a gs:// URL for this object in the form
46
+ * `gs://<bucket>/<path>/<to>/<object>`
47
+ * @returns The gs:// URL.
48
+ */
49
+ toString(): string;
50
+ /**
51
+ * A reference to the root of this object's bucket.
52
+ */
53
+ root: StorageReference;
54
+ /**
55
+ * The name of the bucket containing this reference's object.
56
+ */
57
+ bucket: string;
58
+ /**
59
+ * The full path of this object.
60
+ */
61
+ fullPath: string;
62
+ /**
63
+ * The short name of this object, which is the last component of the full path.
64
+ * For example, if fullPath is 'full/path/image.png', name is 'image.png'.
65
+ */
66
+ name: string;
67
+ /**
68
+ * The {@link FirebaseStorage} instance associated with this reference.
69
+ */
70
+ storage: FirebaseStorage;
71
+ /**
72
+ * A reference pointing to the parent location of this reference, or null if
73
+ * this reference is the root.
74
+ */
75
+ parent: StorageReference | null;
76
+ }
77
+ /**
78
+ * The options `list()` accepts.
79
+ * @public
80
+ */
81
+ export interface ListOptions {
82
+ /**
83
+ * If set, limits the total number of `prefixes` and `items` to return.
84
+ * The default and maximum maxResults is 1000.
85
+ */
86
+ maxResults?: number | null;
87
+ /**
88
+ * The `nextPageToken` from a previous call to `list()`. If provided,
89
+ * listing is resumed from the previous position.
90
+ */
91
+ pageToken?: string | null;
92
+ }
93
+ /**
94
+ * Result returned by list().
95
+ * @public
96
+ */
97
+ export interface ListResult {
98
+ /**
99
+ * References to prefixes (sub-folders). You can call list() on them to
100
+ * get its contents.
101
+ *
102
+ * Folders are implicit based on '/' in the object paths.
103
+ * For example, if a bucket has two objects '/a/b/1' and '/a/b/2', list('/a')
104
+ * will return '/a/b' as a prefix.
105
+ */
106
+ prefixes: StorageReference[];
107
+ /**
108
+ * Objects in this directory.
109
+ * You can call getMetadata() and getDownloadUrl() on them.
110
+ */
111
+ items: StorageReference[];
112
+ /**
113
+ * If set, there might be more results for this list. Use this token to resume the list.
114
+ */
115
+ nextPageToken?: string;
116
+ }
117
+ /**
118
+ * Object metadata that can be set at any time.
119
+ * @public
120
+ */
121
+ export interface SettableMetadata {
122
+ /**
123
+ * Served as the 'Cache-Control' header on object download.
124
+ */
125
+ cacheControl?: string | undefined;
126
+ /**
127
+ * Served as the 'Content-Disposition' header on object download.
128
+ */
129
+ contentDisposition?: string | undefined;
130
+ /**
131
+ * Served as the 'Content-Encoding' header on object download.
132
+ */
133
+ contentEncoding?: string | undefined;
134
+ /**
135
+ * Served as the 'Content-Language' header on object download.
136
+ */
137
+ contentLanguage?: string | undefined;
138
+ /**
139
+ * Served as the 'Content-Type' header on object download.
140
+ */
141
+ contentType?: string | undefined;
142
+ /**
143
+ * Additional user-defined custom metadata.
144
+ */
145
+ customMetadata?: {
146
+ [key: string]: string;
147
+ } | undefined;
148
+ }
149
+ /**
150
+ * Object metadata that can be set at upload.
151
+ * @public
152
+ */
153
+ export interface UploadMetadata extends SettableMetadata {
154
+ /**
155
+ * A Base64-encoded MD5 hash of the object being uploaded.
156
+ */
157
+ md5Hash?: string | undefined;
158
+ }
159
+ /**
160
+ * The full set of object metadata, including read-only properties.
161
+ * @public
162
+ */
163
+ export interface FullMetadata extends UploadMetadata {
164
+ /**
165
+ * The bucket this object is contained in.
166
+ */
167
+ bucket: string;
168
+ /**
169
+ * The full path of this object.
170
+ */
171
+ fullPath: string;
172
+ /**
173
+ * The object's generation.
174
+ * {@link https://cloud.google.com/storage/docs/generations-preconditions}
175
+ */
176
+ generation: string;
177
+ /**
178
+ * The object's metageneration.
179
+ * {@link https://cloud.google.com/storage/docs/generations-preconditions}
180
+ */
181
+ metageneration: string;
182
+ /**
183
+ * The short name of this object, which is the last component of the full path.
184
+ * For example, if fullPath is 'full/path/image.png', name is 'image.png'.
185
+ */
186
+ name: string;
187
+ /**
188
+ * The size of this object, in bytes.
189
+ */
190
+ size: number;
191
+ /**
192
+ * A date string representing when this object was created.
193
+ */
194
+ timeCreated: string;
195
+ /**
196
+ * A date string representing when this object was last updated.
197
+ */
198
+ updated: string;
199
+ /**
200
+ * Tokens to allow access to the downloatd URL.
201
+ */
202
+ downloadTokens: string[] | undefined;
203
+ /**
204
+ * `StorageReference` associated with this upload.
205
+ */
206
+ ref?: StorageReference | undefined;
207
+ }
208
+ /**
209
+ * An event that is triggered on a task.
210
+ * @public
211
+ */
212
+ export declare type TaskEvent = 'state_changed';
213
+ /**
214
+ * Represents the current state of a running upload.
215
+ * @public
216
+ */
217
+ export declare type TaskState = 'running' | 'paused' | 'success' | 'canceled' | 'error';
218
+ /**
219
+ * An error returned by the Firebase Storage SDK.
220
+ * @public
221
+ */
222
+ export interface StorageError extends FirebaseError {
223
+ /**
224
+ * A server response message for the error, if applicable.
225
+ */
226
+ serverResponse: string | null;
227
+ }
228
+ /**
229
+ * A stream observer for Firebase Storage.
230
+ * @public
231
+ */
232
+ export interface StorageObserver<T> {
233
+ next?: NextFn<T> | null;
234
+ error?: (error: StorageError) => void | null;
235
+ complete?: CompleteFn | null;
236
+ }
237
+ /**
238
+ * Represents the process of uploading an object. Allows you to monitor and
239
+ * manage the upload.
240
+ * @public
241
+ */
242
+ export interface UploadTask {
243
+ /**
244
+ * Cancels a running task. Has no effect on a complete or failed task.
245
+ * @returns True if the cancel had an effect.
246
+ */
247
+ cancel(): boolean;
248
+ /**
249
+ * Equivalent to calling `then(null, onRejected)`.
250
+ */
251
+ catch(onRejected: (error: StorageError) => unknown): Promise<unknown>;
252
+ /**
253
+ * Listens for events on this task.
254
+ *
255
+ * Events have three callback functions (referred to as `next`, `error`, and
256
+ * `complete`).
257
+ *
258
+ * If only the event is passed, a function that can be used to register the
259
+ * callbacks is returned. Otherwise, the callbacks are passed after the event.
260
+ *
261
+ * Callbacks can be passed either as three separate arguments <em>or</em> as the
262
+ * `next`, `error`, and `complete` properties of an object. Any of the three
263
+ * callbacks is optional, as long as at least one is specified. In addition,
264
+ * when you add your callbacks, you get a function back. You can call this
265
+ * function to unregister the associated callbacks.
266
+ *
267
+ * @example **Pass callbacks separately or in an object.**
268
+ * ```javascript
269
+ * var next = function(snapshot) {};
270
+ * var error = function(error) {};
271
+ * var complete = function() {};
272
+ *
273
+ * // The first example.
274
+ * uploadTask.on(
275
+ * firebase.storage.TaskEvent.STATE_CHANGED,
276
+ * next,
277
+ * error,
278
+ * complete);
279
+ *
280
+ * // This is equivalent to the first example.
281
+ * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, {
282
+ * 'next': next,
283
+ * 'error': error,
284
+ * 'complete': complete
285
+ * });
286
+ *
287
+ * // This is equivalent to the first example.
288
+ * var subscribe = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED);
289
+ * subscribe(next, error, complete);
290
+ *
291
+ * // This is equivalent to the first example.
292
+ * var subscribe = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED);
293
+ * subscribe({
294
+ * 'next': next,
295
+ * 'error': error,
296
+ * 'complete': complete
297
+ * });
298
+ * ```
299
+ *
300
+ * @example **Any callback is optional.**
301
+ * ```javascript
302
+ * // Just listening for completion, this is legal.
303
+ * uploadTask.on(
304
+ * firebase.storage.TaskEvent.STATE_CHANGED,
305
+ * null,
306
+ * null,
307
+ * function() {
308
+ * console.log('upload complete!');
309
+ * });
310
+ *
311
+ * // Just listening for progress/state changes, this is legal.
312
+ * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, function(snapshot) {
313
+ * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100;
314
+ * console.log(percent + "% done");
315
+ * });
316
+ *
317
+ * // This is also legal.
318
+ * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, {
319
+ * 'complete': function() {
320
+ * console.log('upload complete!');
321
+ * }
322
+ * });
323
+ * ```
324
+ *
325
+ * @example **Use the returned function to remove callbacks.**
326
+ * ```javascript
327
+ * var unsubscribe = uploadTask.on(
328
+ * firebase.storage.TaskEvent.STATE_CHANGED,
329
+ * function(snapshot) {
330
+ * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100;
331
+ * console.log(percent + "% done");
332
+ * // Stop after receiving one update.
333
+ * unsubscribe();
334
+ * });
335
+ *
336
+ * // This code is equivalent to the above.
337
+ * var handle = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED);
338
+ * unsubscribe = handle(function(snapshot) {
339
+ * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100;
340
+ * console.log(percent + "% done");
341
+ * // Stop after receiving one update.
342
+ * unsubscribe();
343
+ * });
344
+ * ```
345
+ *
346
+ * @param event - The type of event to listen for.
347
+ * @param nextOrObserver -
348
+ * The `next` function, which gets called for each item in
349
+ * the event stream, or an observer object with some or all of these three
350
+ * properties (`next`, `error`, `complete`).
351
+ * @param error - A function that gets called with a `StorageError`
352
+ * if the event stream ends due to an error.
353
+ * @param completed - A function that gets called if the
354
+ * event stream ends normally.
355
+ * @returns
356
+ * If only the event argument is passed, returns a function you can use to
357
+ * add callbacks (see the examples above). If more than just the event
358
+ * argument is passed, returns a function you can call to unregister the
359
+ * callbacks.
360
+ */
361
+ on(event: TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError) => unknown) | null, complete?: Unsubscribe | null): Unsubscribe | Subscribe<UploadTaskSnapshot>;
362
+ /**
363
+ * Pauses a currently running task. Has no effect on a paused or failed task.
364
+ * @returns True if the operation took effect, false if ignored.
365
+ */
366
+ pause(): boolean;
367
+ /**
368
+ * Resumes a paused task. Has no effect on a currently running or failed task.
369
+ * @returns True if the operation took effect, false if ignored.
370
+ */
371
+ resume(): boolean;
372
+ /**
373
+ * A snapshot of the current task state.
374
+ */
375
+ snapshot: UploadTaskSnapshot;
376
+ /**
377
+ * This object behaves like a Promise, and resolves with its snapshot data
378
+ * when the upload completes.
379
+ * @param onFulfilled - The fulfillment callback. Promise chaining works as normal.
380
+ * @param onRejected - The rejection callback.
381
+ */
382
+ then(onFulfilled?: ((snapshot: UploadTaskSnapshot) => unknown) | null, onRejected?: ((error: StorageError) => unknown) | null): Promise<unknown>;
383
+ }
384
+ /**
385
+ * Holds data about the current state of the upload task.
386
+ * @public
387
+ */
388
+ export interface UploadTaskSnapshot {
389
+ /**
390
+ * The number of bytes that have been successfully uploaded so far.
391
+ */
392
+ bytesTransferred: number;
393
+ /**
394
+ * Before the upload completes, contains the metadata sent to the server.
395
+ * After the upload completes, contains the metadata sent back from the server.
396
+ */
397
+ metadata: FullMetadata;
398
+ /**
399
+ * The reference that spawned this snapshot's upload task.
400
+ */
401
+ ref: StorageReference;
402
+ /**
403
+ * The current state of the task.
404
+ */
405
+ state: TaskState;
406
+ /**
407
+ * The task of which this is a snapshot.
408
+ */
409
+ task: UploadTask;
410
+ /**
411
+ * The total number of bytes to be uploaded.
412
+ */
413
+ totalBytes: number;
414
+ }
415
+ /**
416
+ * Result returned from a non-resumable upload.
417
+ * @public
418
+ */
419
+ export interface UploadResult {
420
+ /**
421
+ * Contains the metadata sent back from the server.
422
+ */
423
+ readonly metadata: FullMetadata;
424
+ /**
425
+ * The reference that spawned this upload.
426
+ */
427
+ readonly ref: StorageReference;
428
+ }
429
+ declare module '@firebase/component' {
430
+ interface NameServiceMapping {
431
+ 'storage': FirebaseStorage;
432
+ }
433
+ }
@@ -0,0 +1,196 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Location } from './implementation/location';
18
+ import { ListOptions, UploadResult } from './public-types';
19
+ import { StringFormat } from './implementation/string';
20
+ import { Metadata } from './metadata';
21
+ import { FirebaseStorageImpl } from './service';
22
+ import { ListResult } from './list';
23
+ import { UploadTask } from './task';
24
+ /**
25
+ * Provides methods to interact with a bucket in the Firebase Storage service.
26
+ * @internal
27
+ * @param _location - An fbs.location, or the URL at
28
+ * which to base this object, in one of the following forms:
29
+ * gs://<bucket>/<object-path>
30
+ * http[s]://firebasestorage.googleapis.com/
31
+ * <api-version>/b/<bucket>/o/<object-path>
32
+ * Any query or fragment strings will be ignored in the http[s]
33
+ * format. If no value is passed, the storage object will use a URL based on
34
+ * the project ID of the base firebase.App instance.
35
+ */
36
+ export declare class Reference {
37
+ private _service;
38
+ _location: Location;
39
+ constructor(_service: FirebaseStorageImpl, location: string | Location);
40
+ /**
41
+ * Returns the URL for the bucket and path this object references,
42
+ * in the form gs://<bucket>/<object-path>
43
+ * @override
44
+ */
45
+ toString(): string;
46
+ protected _newRef(service: FirebaseStorageImpl, location: Location): Reference;
47
+ /**
48
+ * A reference to the root of this object's bucket.
49
+ */
50
+ get root(): Reference;
51
+ /**
52
+ * The name of the bucket containing this reference's object.
53
+ */
54
+ get bucket(): string;
55
+ /**
56
+ * The full path of this object.
57
+ */
58
+ get fullPath(): string;
59
+ /**
60
+ * The short name of this object, which is the last component of the full path.
61
+ * For example, if fullPath is 'full/path/image.png', name is 'image.png'.
62
+ */
63
+ get name(): string;
64
+ /**
65
+ * The `StorageService` instance this `StorageReference` is associated with.
66
+ */
67
+ get storage(): FirebaseStorageImpl;
68
+ /**
69
+ * A `StorageReference` pointing to the parent location of this `StorageReference`, or null if
70
+ * this reference is the root.
71
+ */
72
+ get parent(): Reference | null;
73
+ /**
74
+ * Utility function to throw an error in methods that do not accept a root reference.
75
+ */
76
+ _throwIfRoot(name: string): void;
77
+ }
78
+ /**
79
+ * Uploads data to this object's location.
80
+ * The upload is not resumable.
81
+ *
82
+ * @param ref - StorageReference where data should be uploaded.
83
+ * @param data - The data to upload.
84
+ * @param metadata - Metadata for the newly uploaded data.
85
+ * @returns A Promise containing an UploadResult
86
+ */
87
+ export declare function uploadBytes(ref: Reference, data: Blob | Uint8Array | ArrayBuffer, metadata?: Metadata): Promise<UploadResult>;
88
+ /**
89
+ * Uploads data to this object's location.
90
+ * The upload can be paused and resumed, and exposes progress updates.
91
+ * @public
92
+ * @param ref - StorageReference where data should be uploaded.
93
+ * @param data - The data to upload.
94
+ * @param metadata - Metadata for the newly uploaded data.
95
+ * @returns An UploadTask
96
+ */
97
+ export declare function uploadBytesResumable(ref: Reference, data: Blob | Uint8Array | ArrayBuffer, metadata?: Metadata): UploadTask;
98
+ /**
99
+ * Uploads a string to this object's location.
100
+ * The upload is not resumable.
101
+ * @public
102
+ * @param ref - StorageReference where string should be uploaded.
103
+ * @param value - The string to upload.
104
+ * @param format - The format of the string to upload.
105
+ * @param metadata - Metadata for the newly uploaded string.
106
+ * @returns A Promise containing an UploadResult
107
+ */
108
+ export declare function uploadString(ref: Reference, value: string, format?: StringFormat, metadata?: Metadata): Promise<UploadResult>;
109
+ /**
110
+ * List all items (files) and prefixes (folders) under this storage reference.
111
+ *
112
+ * This is a helper method for calling list() repeatedly until there are
113
+ * no more results. The default pagination size is 1000.
114
+ *
115
+ * Note: The results may not be consistent if objects are changed while this
116
+ * operation is running.
117
+ *
118
+ * Warning: listAll may potentially consume too many resources if there are
119
+ * too many results.
120
+ * @public
121
+ * @param ref - StorageReference to get list from.
122
+ *
123
+ * @returns A Promise that resolves with all the items and prefixes under
124
+ * the current storage reference. `prefixes` contains references to
125
+ * sub-directories and `items` contains references to objects in this
126
+ * folder. `nextPageToken` is never returned.
127
+ */
128
+ export declare function listAll(ref: Reference): Promise<ListResult>;
129
+ /**
130
+ * List items (files) and prefixes (folders) under this storage reference.
131
+ *
132
+ * List API is only available for Firebase Rules Version 2.
133
+ *
134
+ * GCS is a key-blob store. Firebase Storage imposes the semantic of '/'
135
+ * delimited folder structure.
136
+ * Refer to GCS's List API if you want to learn more.
137
+ *
138
+ * To adhere to Firebase Rules's Semantics, Firebase Storage does not
139
+ * support objects whose paths end with "/" or contain two consecutive
140
+ * "/"s. Firebase Storage List API will filter these unsupported objects.
141
+ * list() may fail if there are too many unsupported objects in the bucket.
142
+ * @public
143
+ *
144
+ * @param ref - StorageReference to get list from.
145
+ * @param options - See ListOptions for details.
146
+ * @returns A Promise that resolves with the items and prefixes.
147
+ * `prefixes` contains references to sub-folders and `items`
148
+ * contains references to objects in this folder. `nextPageToken`
149
+ * can be used to get the rest of the results.
150
+ */
151
+ export declare function list(ref: Reference, options?: ListOptions | null): Promise<ListResult>;
152
+ /**
153
+ * A `Promise` that resolves with the metadata for this object. If this
154
+ * object doesn't exist or metadata cannot be retreived, the promise is
155
+ * rejected.
156
+ * @public
157
+ * @param ref - StorageReference to get metadata from.
158
+ */
159
+ export declare function getMetadata(ref: Reference): Promise<Metadata>;
160
+ /**
161
+ * Updates the metadata for this object.
162
+ * @public
163
+ * @param ref - StorageReference to update metadata for.
164
+ * @param metadata - The new metadata for the object.
165
+ * Only values that have been explicitly set will be changed. Explicitly
166
+ * setting a value to null will remove the metadata.
167
+ * @returns A `Promise` that resolves
168
+ * with the new metadata for this object.
169
+ * See `firebaseStorage.Reference.prototype.getMetadata`
170
+ */
171
+ export declare function updateMetadata(ref: Reference, metadata: Partial<Metadata>): Promise<Metadata>;
172
+ /**
173
+ * Returns the download URL for the given Reference.
174
+ * @public
175
+ * @returns A `Promise` that resolves with the download
176
+ * URL for this object.
177
+ */
178
+ export declare function getDownloadURL(ref: Reference): Promise<string>;
179
+ /**
180
+ * Deletes the object at this location.
181
+ * @public
182
+ * @param ref - StorageReference for object to delete.
183
+ * @returns A `Promise` that resolves if the deletion succeeds.
184
+ */
185
+ export declare function deleteObject(ref: Reference): Promise<void>;
186
+ /**
187
+ * Returns reference for object obtained by appending `childPath` to `ref`.
188
+ *
189
+ * @param ref - StorageReference to get child of.
190
+ * @param childPath - Child path from provided ref.
191
+ * @returns A reference to the object obtained by
192
+ * appending childPath, removing any duplicate, beginning, or trailing
193
+ * slashes.
194
+ *
195
+ */
196
+ export declare function _getChild(ref: Reference, childPath: string): Reference;