@firebase/storage 0.13.3 → 0.13.4
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.
- package/dist/index.browser.cjs.js +3571 -3571
- package/dist/index.browser.cjs.js.map +1 -1
- package/dist/index.cjs.js +3571 -3571
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +3571 -3571
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.node.cjs.js +3596 -3596
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/node-esm/index.node.esm.js +3596 -3596
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/api.browser.d.ts +47 -47
- package/dist/node-esm/src/api.d.ts +200 -200
- package/dist/node-esm/src/api.node.d.ts +47 -47
- package/dist/node-esm/src/constants.d.ts +20 -20
- package/dist/node-esm/src/implementation/async.d.ts +22 -22
- package/dist/node-esm/src/implementation/backoff.d.ts +43 -43
- package/dist/node-esm/src/implementation/blob.d.ts +34 -34
- package/dist/node-esm/src/implementation/connection.d.ts +56 -56
- package/dist/node-esm/src/implementation/constants.d.ts +48 -48
- package/dist/node-esm/src/implementation/error.d.ts +126 -126
- package/dist/node-esm/src/implementation/failrequest.d.ts +29 -29
- package/dist/node-esm/src/implementation/fs.d.ts +17 -17
- package/dist/node-esm/src/implementation/json.d.ts +7 -7
- package/dist/node-esm/src/implementation/list.d.ts +19 -19
- package/dist/node-esm/src/implementation/location.d.ts +32 -32
- package/dist/node-esm/src/implementation/metadata.d.ts +40 -40
- package/dist/node-esm/src/implementation/observer.d.ts +47 -47
- package/dist/node-esm/src/implementation/path.d.ts +31 -31
- package/dist/node-esm/src/implementation/request.d.ts +47 -47
- package/dist/node-esm/src/implementation/requestinfo.d.ts +73 -73
- package/dist/node-esm/src/implementation/requests.d.ts +84 -84
- package/dist/node-esm/src/implementation/string.d.ts +73 -73
- package/dist/node-esm/src/implementation/taskenums.d.ts +77 -77
- package/dist/node-esm/src/implementation/type.d.ts +23 -23
- package/dist/node-esm/src/implementation/url.d.ts +22 -22
- package/dist/node-esm/src/implementation/utils.d.ts +23 -23
- package/dist/node-esm/src/index.d.ts +7 -7
- package/dist/node-esm/src/index.node.d.ts +7 -7
- package/dist/node-esm/src/list.d.ts +41 -41
- package/dist/node-esm/src/metadata.d.ts +27 -27
- package/dist/node-esm/src/platform/base64.d.ts +20 -20
- package/dist/node-esm/src/platform/browser/base64.d.ts +19 -19
- package/dist/node-esm/src/platform/browser/connection.d.ts +55 -55
- package/dist/node-esm/src/platform/connection.d.ts +22 -22
- package/dist/node-esm/src/platform/node/base64.d.ts +19 -19
- package/dist/node-esm/src/platform/node/connection.d.ts +58 -59
- package/dist/node-esm/src/public-types.d.ts +424 -424
- package/dist/node-esm/src/reference.d.ts +208 -208
- package/dist/node-esm/src/service.d.ts +130 -130
- package/dist/node-esm/src/task.d.ts +148 -148
- package/dist/node-esm/test/browser/blob.test.d.ts +17 -17
- package/dist/node-esm/test/browser/connection.test.d.ts +17 -17
- package/dist/node-esm/test/browser/string.browser.test.d.ts +17 -17
- package/dist/node-esm/test/integration/integration.test.d.ts +24 -24
- package/dist/node-esm/test/node/connection.test.d.ts +17 -17
- package/dist/node-esm/test/node/stream.test.d.ts +17 -17
- package/dist/node-esm/test/unit/connection.d.ts +47 -47
- package/dist/node-esm/test/unit/index.test.d.ts +4 -4
- package/dist/node-esm/test/unit/location.test.d.ts +1 -1
- package/dist/node-esm/test/unit/reference.test.d.ts +1 -1
- package/dist/node-esm/test/unit/request.test.d.ts +1 -1
- package/dist/node-esm/test/unit/requests.test.d.ts +1 -1
- package/dist/node-esm/test/unit/service.test.d.ts +1 -1
- package/dist/node-esm/test/unit/string.test.d.ts +1 -1
- package/dist/node-esm/test/unit/task.test.d.ts +1 -1
- package/dist/node-esm/test/unit/testshared.d.ts +60 -60
- package/dist/node-esm/test/unit/utils.test.d.ts +17 -17
- package/dist/src/api.browser.d.ts +47 -47
- package/dist/src/api.d.ts +200 -200
- package/dist/src/api.node.d.ts +47 -47
- package/dist/src/constants.d.ts +20 -20
- package/dist/src/implementation/async.d.ts +22 -22
- package/dist/src/implementation/backoff.d.ts +43 -43
- package/dist/src/implementation/blob.d.ts +34 -34
- package/dist/src/implementation/connection.d.ts +56 -56
- package/dist/src/implementation/constants.d.ts +48 -48
- package/dist/src/implementation/error.d.ts +126 -126
- package/dist/src/implementation/failrequest.d.ts +29 -29
- package/dist/src/implementation/fs.d.ts +17 -17
- package/dist/src/implementation/json.d.ts +7 -7
- package/dist/src/implementation/list.d.ts +19 -19
- package/dist/src/implementation/location.d.ts +32 -32
- package/dist/src/implementation/metadata.d.ts +40 -40
- package/dist/src/implementation/observer.d.ts +47 -47
- package/dist/src/implementation/path.d.ts +31 -31
- package/dist/src/implementation/request.d.ts +47 -47
- package/dist/src/implementation/requestinfo.d.ts +73 -73
- package/dist/src/implementation/requests.d.ts +84 -84
- package/dist/src/implementation/string.d.ts +73 -73
- package/dist/src/implementation/taskenums.d.ts +77 -77
- package/dist/src/implementation/type.d.ts +23 -23
- package/dist/src/implementation/url.d.ts +22 -22
- package/dist/src/implementation/utils.d.ts +23 -23
- package/dist/src/index.d.ts +7 -7
- package/dist/src/index.node.d.ts +7 -7
- package/dist/src/list.d.ts +41 -41
- package/dist/src/metadata.d.ts +27 -27
- package/dist/src/platform/base64.d.ts +20 -20
- package/dist/src/platform/browser/base64.d.ts +19 -19
- package/dist/src/platform/browser/connection.d.ts +55 -55
- package/dist/src/platform/connection.d.ts +22 -22
- package/dist/src/platform/node/base64.d.ts +19 -19
- package/dist/src/platform/node/connection.d.ts +58 -59
- package/dist/src/public-types.d.ts +424 -424
- package/dist/src/reference.d.ts +208 -208
- package/dist/src/service.d.ts +130 -130
- package/dist/src/task.d.ts +148 -148
- package/dist/test/browser/blob.test.d.ts +17 -17
- package/dist/test/browser/connection.test.d.ts +17 -17
- package/dist/test/browser/string.browser.test.d.ts +17 -17
- package/dist/test/integration/integration.test.d.ts +24 -24
- package/dist/test/node/connection.test.d.ts +17 -17
- package/dist/test/node/stream.test.d.ts +17 -17
- package/dist/test/unit/connection.d.ts +47 -47
- package/dist/test/unit/index.test.d.ts +4 -4
- package/dist/test/unit/location.test.d.ts +1 -1
- package/dist/test/unit/reference.test.d.ts +1 -1
- package/dist/test/unit/request.test.d.ts +1 -1
- package/dist/test/unit/requests.test.d.ts +1 -1
- package/dist/test/unit/service.test.d.ts +1 -1
- package/dist/test/unit/string.test.d.ts +1 -1
- package/dist/test/unit/task.test.d.ts +1 -1
- package/dist/test/unit/testshared.d.ts +60 -60
- package/dist/test/unit/utils.test.d.ts +17 -17
- package/package.json +6 -6
|
@@ -1,424 +1,424 @@
|
|
|
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, NextFn, Subscribe, Unsubscribe } from '@firebase/util';
|
|
19
|
-
import { StorageError } from './implementation/error';
|
|
20
|
-
/**
|
|
21
|
-
* A Firebase Storage instance.
|
|
22
|
-
* @public
|
|
23
|
-
*/
|
|
24
|
-
export interface FirebaseStorage extends _FirebaseService {
|
|
25
|
-
/**
|
|
26
|
-
* The {@link @firebase/app#FirebaseApp} associated with this `FirebaseStorage` instance.
|
|
27
|
-
*/
|
|
28
|
-
readonly app: FirebaseApp;
|
|
29
|
-
/**
|
|
30
|
-
* The maximum time to retry uploads in milliseconds.
|
|
31
|
-
*/
|
|
32
|
-
maxUploadRetryTime: number;
|
|
33
|
-
/**
|
|
34
|
-
* The maximum time to retry operations other than uploads or downloads in
|
|
35
|
-
* milliseconds.
|
|
36
|
-
*/
|
|
37
|
-
maxOperationRetryTime: number;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Represents a reference to a Google Cloud Storage object. Developers can
|
|
41
|
-
* upload, download, and delete objects, as well as get/set object metadata.
|
|
42
|
-
* @public
|
|
43
|
-
*/
|
|
44
|
-
export interface StorageReference {
|
|
45
|
-
/**
|
|
46
|
-
* Returns a gs:// URL for this object in the form
|
|
47
|
-
* `gs://<bucket>/<path>/<to>/<object>`
|
|
48
|
-
* @returns The gs:// URL.
|
|
49
|
-
*/
|
|
50
|
-
toString(): string;
|
|
51
|
-
/**
|
|
52
|
-
* A reference to the root of this object's bucket.
|
|
53
|
-
*/
|
|
54
|
-
root: StorageReference;
|
|
55
|
-
/**
|
|
56
|
-
* The name of the bucket containing this reference's object.
|
|
57
|
-
*/
|
|
58
|
-
bucket: string;
|
|
59
|
-
/**
|
|
60
|
-
* The full path of this object.
|
|
61
|
-
*/
|
|
62
|
-
fullPath: string;
|
|
63
|
-
/**
|
|
64
|
-
* The short name of this object, which is the last component of the full path.
|
|
65
|
-
* For example, if fullPath is 'full/path/image.png', name is 'image.png'.
|
|
66
|
-
*/
|
|
67
|
-
name: string;
|
|
68
|
-
/**
|
|
69
|
-
* The {@link FirebaseStorage} instance associated with this reference.
|
|
70
|
-
*/
|
|
71
|
-
storage: FirebaseStorage;
|
|
72
|
-
/**
|
|
73
|
-
* A reference pointing to the parent location of this reference, or null if
|
|
74
|
-
* this reference is the root.
|
|
75
|
-
*/
|
|
76
|
-
parent: StorageReference | null;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* The options `list()` accepts.
|
|
80
|
-
* @public
|
|
81
|
-
*/
|
|
82
|
-
export interface ListOptions {
|
|
83
|
-
/**
|
|
84
|
-
* If set, limits the total number of `prefixes` and `items` to return.
|
|
85
|
-
* The default and maximum maxResults is 1000.
|
|
86
|
-
*/
|
|
87
|
-
maxResults?: number | null;
|
|
88
|
-
/**
|
|
89
|
-
* The `nextPageToken` from a previous call to `list()`. If provided,
|
|
90
|
-
* listing is resumed from the previous position.
|
|
91
|
-
*/
|
|
92
|
-
pageToken?: string | null;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Result returned by list().
|
|
96
|
-
* @public
|
|
97
|
-
*/
|
|
98
|
-
export interface ListResult {
|
|
99
|
-
/**
|
|
100
|
-
* References to prefixes (sub-folders). You can call list() on them to
|
|
101
|
-
* get its contents.
|
|
102
|
-
*
|
|
103
|
-
* Folders are implicit based on '/' in the object paths.
|
|
104
|
-
* For example, if a bucket has two objects '/a/b/1' and '/a/b/2', list('/a')
|
|
105
|
-
* will return '/a/b' as a prefix.
|
|
106
|
-
*/
|
|
107
|
-
prefixes: StorageReference[];
|
|
108
|
-
/**
|
|
109
|
-
* Objects in this directory.
|
|
110
|
-
* You can call getMetadata() and getDownloadUrl() on them.
|
|
111
|
-
*/
|
|
112
|
-
items: StorageReference[];
|
|
113
|
-
/**
|
|
114
|
-
* If set, there might be more results for this list. Use this token to resume the list.
|
|
115
|
-
*/
|
|
116
|
-
nextPageToken?: string;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Object metadata that can be set at any time.
|
|
120
|
-
* @public
|
|
121
|
-
*/
|
|
122
|
-
export interface SettableMetadata {
|
|
123
|
-
/**
|
|
124
|
-
* Served as the 'Cache-Control' header on object download.
|
|
125
|
-
*/
|
|
126
|
-
cacheControl?: string | undefined;
|
|
127
|
-
/**
|
|
128
|
-
* Served as the 'Content-Disposition' header on object download.
|
|
129
|
-
*/
|
|
130
|
-
contentDisposition?: string | undefined;
|
|
131
|
-
/**
|
|
132
|
-
* Served as the 'Content-Encoding' header on object download.
|
|
133
|
-
*/
|
|
134
|
-
contentEncoding?: string | undefined;
|
|
135
|
-
/**
|
|
136
|
-
* Served as the 'Content-Language' header on object download.
|
|
137
|
-
*/
|
|
138
|
-
contentLanguage?: string | undefined;
|
|
139
|
-
/**
|
|
140
|
-
* Served as the 'Content-Type' header on object download.
|
|
141
|
-
*/
|
|
142
|
-
contentType?: string | undefined;
|
|
143
|
-
/**
|
|
144
|
-
* Additional user-defined custom metadata.
|
|
145
|
-
*/
|
|
146
|
-
customMetadata?: {
|
|
147
|
-
[key: string]: string;
|
|
148
|
-
} | undefined;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Object metadata that can be set at upload.
|
|
152
|
-
* @public
|
|
153
|
-
*/
|
|
154
|
-
export interface UploadMetadata extends SettableMetadata {
|
|
155
|
-
/**
|
|
156
|
-
* A Base64-encoded MD5 hash of the object being uploaded.
|
|
157
|
-
*/
|
|
158
|
-
md5Hash?: string | undefined;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* The full set of object metadata, including read-only properties.
|
|
162
|
-
* @public
|
|
163
|
-
*/
|
|
164
|
-
export interface FullMetadata extends UploadMetadata {
|
|
165
|
-
/**
|
|
166
|
-
* The bucket this object is contained in.
|
|
167
|
-
*/
|
|
168
|
-
bucket: string;
|
|
169
|
-
/**
|
|
170
|
-
* The full path of this object.
|
|
171
|
-
*/
|
|
172
|
-
fullPath: string;
|
|
173
|
-
/**
|
|
174
|
-
* The object's generation.
|
|
175
|
-
* {@link https://cloud.google.com/storage/docs/metadata#generation-number}
|
|
176
|
-
*/
|
|
177
|
-
generation: string;
|
|
178
|
-
/**
|
|
179
|
-
* The object's metageneration.
|
|
180
|
-
* {@link https://cloud.google.com/storage/docs/metadata#generation-number}
|
|
181
|
-
*/
|
|
182
|
-
metageneration: string;
|
|
183
|
-
/**
|
|
184
|
-
* The short name of this object, which is the last component of the full path.
|
|
185
|
-
* For example, if fullPath is 'full/path/image.png', name is 'image.png'.
|
|
186
|
-
*/
|
|
187
|
-
name: string;
|
|
188
|
-
/**
|
|
189
|
-
* The size of this object, in bytes.
|
|
190
|
-
*/
|
|
191
|
-
size: number;
|
|
192
|
-
/**
|
|
193
|
-
* A date string representing when this object was created.
|
|
194
|
-
*/
|
|
195
|
-
timeCreated: string;
|
|
196
|
-
/**
|
|
197
|
-
* A date string representing when this object was last updated.
|
|
198
|
-
*/
|
|
199
|
-
updated: string;
|
|
200
|
-
/**
|
|
201
|
-
* Tokens to allow access to the download URL.
|
|
202
|
-
*/
|
|
203
|
-
downloadTokens: string[] | undefined;
|
|
204
|
-
/**
|
|
205
|
-
* `StorageReference` associated with this upload.
|
|
206
|
-
*/
|
|
207
|
-
ref?: StorageReference | undefined;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* An event that is triggered on a task.
|
|
211
|
-
* @public
|
|
212
|
-
*/
|
|
213
|
-
export
|
|
214
|
-
/**
|
|
215
|
-
* Represents the current state of a running upload.
|
|
216
|
-
* @public
|
|
217
|
-
*/
|
|
218
|
-
export
|
|
219
|
-
/**
|
|
220
|
-
* A stream observer for Firebase Storage.
|
|
221
|
-
* @public
|
|
222
|
-
*/
|
|
223
|
-
export interface StorageObserver<T> {
|
|
224
|
-
next?: NextFn<T> | null;
|
|
225
|
-
error?: (error: StorageError) => void | null;
|
|
226
|
-
complete?: CompleteFn | null;
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Represents the process of uploading an object. Allows you to monitor and
|
|
230
|
-
* manage the upload.
|
|
231
|
-
* @public
|
|
232
|
-
*/
|
|
233
|
-
export interface UploadTask {
|
|
234
|
-
/**
|
|
235
|
-
* Cancels a running task. Has no effect on a complete or failed task.
|
|
236
|
-
* @returns True if the cancel had an effect.
|
|
237
|
-
*/
|
|
238
|
-
cancel(): boolean;
|
|
239
|
-
/**
|
|
240
|
-
* Equivalent to calling `then(null, onRejected)`.
|
|
241
|
-
*/
|
|
242
|
-
catch(onRejected: (error: StorageError) => unknown): Promise<unknown>;
|
|
243
|
-
/**
|
|
244
|
-
* Listens for events on this task.
|
|
245
|
-
*
|
|
246
|
-
* Events have three callback functions (referred to as `next`, `error`, and
|
|
247
|
-
* `complete`).
|
|
248
|
-
*
|
|
249
|
-
* If only the event is passed, a function that can be used to register the
|
|
250
|
-
* callbacks is returned. Otherwise, the callbacks are passed after the event.
|
|
251
|
-
*
|
|
252
|
-
* Callbacks can be passed either as three separate arguments <em>or</em> as the
|
|
253
|
-
* `next`, `error`, and `complete` properties of an object. Any of the three
|
|
254
|
-
* callbacks is optional, as long as at least one is specified. In addition,
|
|
255
|
-
* when you add your callbacks, you get a function back. You can call this
|
|
256
|
-
* function to unregister the associated callbacks.
|
|
257
|
-
*
|
|
258
|
-
* @example **Pass callbacks separately or in an object.**
|
|
259
|
-
* ```javascript
|
|
260
|
-
* var next = function(snapshot) {};
|
|
261
|
-
* var error = function(error) {};
|
|
262
|
-
* var complete = function() {};
|
|
263
|
-
*
|
|
264
|
-
* // The first example.
|
|
265
|
-
* uploadTask.on(
|
|
266
|
-
* firebase.storage.TaskEvent.STATE_CHANGED,
|
|
267
|
-
* next,
|
|
268
|
-
* error,
|
|
269
|
-
* complete);
|
|
270
|
-
*
|
|
271
|
-
* // This is equivalent to the first example.
|
|
272
|
-
* uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, {
|
|
273
|
-
* 'next': next,
|
|
274
|
-
* 'error': error,
|
|
275
|
-
* 'complete': complete
|
|
276
|
-
* });
|
|
277
|
-
*
|
|
278
|
-
* // This is equivalent to the first example.
|
|
279
|
-
* var subscribe = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED);
|
|
280
|
-
* subscribe(next, error, complete);
|
|
281
|
-
*
|
|
282
|
-
* // This is equivalent to the first example.
|
|
283
|
-
* var subscribe = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED);
|
|
284
|
-
* subscribe({
|
|
285
|
-
* 'next': next,
|
|
286
|
-
* 'error': error,
|
|
287
|
-
* 'complete': complete
|
|
288
|
-
* });
|
|
289
|
-
* ```
|
|
290
|
-
*
|
|
291
|
-
* @example **Any callback is optional.**
|
|
292
|
-
* ```javascript
|
|
293
|
-
* // Just listening for completion, this is legal.
|
|
294
|
-
* uploadTask.on(
|
|
295
|
-
* firebase.storage.TaskEvent.STATE_CHANGED,
|
|
296
|
-
* null,
|
|
297
|
-
* null,
|
|
298
|
-
* function() {
|
|
299
|
-
* console.log('upload complete!');
|
|
300
|
-
* });
|
|
301
|
-
*
|
|
302
|
-
* // Just listening for progress/state changes, this is legal.
|
|
303
|
-
* uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, function(snapshot) {
|
|
304
|
-
* var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100;
|
|
305
|
-
* console.log(percent + "% done");
|
|
306
|
-
* });
|
|
307
|
-
*
|
|
308
|
-
* // This is also legal.
|
|
309
|
-
* uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, {
|
|
310
|
-
* 'complete': function() {
|
|
311
|
-
* console.log('upload complete!');
|
|
312
|
-
* }
|
|
313
|
-
* });
|
|
314
|
-
* ```
|
|
315
|
-
*
|
|
316
|
-
* @example **Use the returned function to remove callbacks.**
|
|
317
|
-
* ```javascript
|
|
318
|
-
* var unsubscribe = uploadTask.on(
|
|
319
|
-
* firebase.storage.TaskEvent.STATE_CHANGED,
|
|
320
|
-
* function(snapshot) {
|
|
321
|
-
* var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100;
|
|
322
|
-
* console.log(percent + "% done");
|
|
323
|
-
* // Stop after receiving one update.
|
|
324
|
-
* unsubscribe();
|
|
325
|
-
* });
|
|
326
|
-
*
|
|
327
|
-
* // This code is equivalent to the above.
|
|
328
|
-
* var handle = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED);
|
|
329
|
-
* unsubscribe = handle(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
|
-
*
|
|
337
|
-
* @param event - The type of event to listen for.
|
|
338
|
-
* @param nextOrObserver -
|
|
339
|
-
* The `next` function, which gets called for each item in
|
|
340
|
-
* the event stream, or an observer object with some or all of these three
|
|
341
|
-
* properties (`next`, `error`, `complete`).
|
|
342
|
-
* @param error - A function that gets called with a `StorageError`
|
|
343
|
-
* if the event stream ends due to an error.
|
|
344
|
-
* @param completed - A function that gets called if the
|
|
345
|
-
* event stream ends normally.
|
|
346
|
-
* @returns
|
|
347
|
-
* If only the event argument is passed, returns a function you can use to
|
|
348
|
-
* add callbacks (see the examples above). If more than just the event
|
|
349
|
-
* argument is passed, returns a function you can call to unregister the
|
|
350
|
-
* callbacks.
|
|
351
|
-
*/
|
|
352
|
-
on(event: TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError) => unknown) | null, complete?: Unsubscribe | null): Unsubscribe | Subscribe<UploadTaskSnapshot>;
|
|
353
|
-
/**
|
|
354
|
-
* Pauses a currently running task. Has no effect on a paused or failed task.
|
|
355
|
-
* @returns True if the operation took effect, false if ignored.
|
|
356
|
-
*/
|
|
357
|
-
pause(): boolean;
|
|
358
|
-
/**
|
|
359
|
-
* Resumes a paused task. Has no effect on a currently running or failed task.
|
|
360
|
-
* @returns True if the operation took effect, false if ignored.
|
|
361
|
-
*/
|
|
362
|
-
resume(): boolean;
|
|
363
|
-
/**
|
|
364
|
-
* A snapshot of the current task state.
|
|
365
|
-
*/
|
|
366
|
-
snapshot: UploadTaskSnapshot;
|
|
367
|
-
/**
|
|
368
|
-
* This object behaves like a Promise, and resolves with its snapshot data
|
|
369
|
-
* when the upload completes.
|
|
370
|
-
* @param onFulfilled - The fulfillment callback. Promise chaining works as normal.
|
|
371
|
-
* @param onRejected - The rejection callback.
|
|
372
|
-
*/
|
|
373
|
-
then(onFulfilled?: ((snapshot: UploadTaskSnapshot) => unknown) | null, onRejected?: ((error: StorageError) => unknown) | null): Promise<unknown>;
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* Holds data about the current state of the upload task.
|
|
377
|
-
* @public
|
|
378
|
-
*/
|
|
379
|
-
export interface UploadTaskSnapshot {
|
|
380
|
-
/**
|
|
381
|
-
* The number of bytes that have been successfully uploaded so far.
|
|
382
|
-
*/
|
|
383
|
-
bytesTransferred: number;
|
|
384
|
-
/**
|
|
385
|
-
* Before the upload completes, contains the metadata sent to the server.
|
|
386
|
-
* After the upload completes, contains the metadata sent back from the server.
|
|
387
|
-
*/
|
|
388
|
-
metadata: FullMetadata;
|
|
389
|
-
/**
|
|
390
|
-
* The reference that spawned this snapshot's upload task.
|
|
391
|
-
*/
|
|
392
|
-
ref: StorageReference;
|
|
393
|
-
/**
|
|
394
|
-
* The current state of the task.
|
|
395
|
-
*/
|
|
396
|
-
state: TaskState;
|
|
397
|
-
/**
|
|
398
|
-
* The task of which this is a snapshot.
|
|
399
|
-
*/
|
|
400
|
-
task: UploadTask;
|
|
401
|
-
/**
|
|
402
|
-
* The total number of bytes to be uploaded.
|
|
403
|
-
*/
|
|
404
|
-
totalBytes: number;
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Result returned from a non-resumable upload.
|
|
408
|
-
* @public
|
|
409
|
-
*/
|
|
410
|
-
export interface UploadResult {
|
|
411
|
-
/**
|
|
412
|
-
* Contains the metadata sent back from the server.
|
|
413
|
-
*/
|
|
414
|
-
readonly metadata: FullMetadata;
|
|
415
|
-
/**
|
|
416
|
-
* The reference that spawned this upload.
|
|
417
|
-
*/
|
|
418
|
-
readonly ref: StorageReference;
|
|
419
|
-
}
|
|
420
|
-
declare module '@firebase/component' {
|
|
421
|
-
interface NameServiceMapping {
|
|
422
|
-
'storage': FirebaseStorage;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
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, NextFn, Subscribe, Unsubscribe } from '@firebase/util';
|
|
19
|
+
import { StorageError } from './implementation/error';
|
|
20
|
+
/**
|
|
21
|
+
* A Firebase Storage instance.
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export interface FirebaseStorage extends _FirebaseService {
|
|
25
|
+
/**
|
|
26
|
+
* The {@link @firebase/app#FirebaseApp} associated with this `FirebaseStorage` instance.
|
|
27
|
+
*/
|
|
28
|
+
readonly app: FirebaseApp;
|
|
29
|
+
/**
|
|
30
|
+
* The maximum time to retry uploads in milliseconds.
|
|
31
|
+
*/
|
|
32
|
+
maxUploadRetryTime: number;
|
|
33
|
+
/**
|
|
34
|
+
* The maximum time to retry operations other than uploads or downloads in
|
|
35
|
+
* milliseconds.
|
|
36
|
+
*/
|
|
37
|
+
maxOperationRetryTime: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Represents a reference to a Google Cloud Storage object. Developers can
|
|
41
|
+
* upload, download, and delete objects, as well as get/set object metadata.
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export interface StorageReference {
|
|
45
|
+
/**
|
|
46
|
+
* Returns a gs:// URL for this object in the form
|
|
47
|
+
* `gs://<bucket>/<path>/<to>/<object>`
|
|
48
|
+
* @returns The gs:// URL.
|
|
49
|
+
*/
|
|
50
|
+
toString(): string;
|
|
51
|
+
/**
|
|
52
|
+
* A reference to the root of this object's bucket.
|
|
53
|
+
*/
|
|
54
|
+
root: StorageReference;
|
|
55
|
+
/**
|
|
56
|
+
* The name of the bucket containing this reference's object.
|
|
57
|
+
*/
|
|
58
|
+
bucket: string;
|
|
59
|
+
/**
|
|
60
|
+
* The full path of this object.
|
|
61
|
+
*/
|
|
62
|
+
fullPath: string;
|
|
63
|
+
/**
|
|
64
|
+
* The short name of this object, which is the last component of the full path.
|
|
65
|
+
* For example, if fullPath is 'full/path/image.png', name is 'image.png'.
|
|
66
|
+
*/
|
|
67
|
+
name: string;
|
|
68
|
+
/**
|
|
69
|
+
* The {@link FirebaseStorage} instance associated with this reference.
|
|
70
|
+
*/
|
|
71
|
+
storage: FirebaseStorage;
|
|
72
|
+
/**
|
|
73
|
+
* A reference pointing to the parent location of this reference, or null if
|
|
74
|
+
* this reference is the root.
|
|
75
|
+
*/
|
|
76
|
+
parent: StorageReference | null;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The options `list()` accepts.
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
export interface ListOptions {
|
|
83
|
+
/**
|
|
84
|
+
* If set, limits the total number of `prefixes` and `items` to return.
|
|
85
|
+
* The default and maximum maxResults is 1000.
|
|
86
|
+
*/
|
|
87
|
+
maxResults?: number | null;
|
|
88
|
+
/**
|
|
89
|
+
* The `nextPageToken` from a previous call to `list()`. If provided,
|
|
90
|
+
* listing is resumed from the previous position.
|
|
91
|
+
*/
|
|
92
|
+
pageToken?: string | null;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Result returned by list().
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
export interface ListResult {
|
|
99
|
+
/**
|
|
100
|
+
* References to prefixes (sub-folders). You can call list() on them to
|
|
101
|
+
* get its contents.
|
|
102
|
+
*
|
|
103
|
+
* Folders are implicit based on '/' in the object paths.
|
|
104
|
+
* For example, if a bucket has two objects '/a/b/1' and '/a/b/2', list('/a')
|
|
105
|
+
* will return '/a/b' as a prefix.
|
|
106
|
+
*/
|
|
107
|
+
prefixes: StorageReference[];
|
|
108
|
+
/**
|
|
109
|
+
* Objects in this directory.
|
|
110
|
+
* You can call getMetadata() and getDownloadUrl() on them.
|
|
111
|
+
*/
|
|
112
|
+
items: StorageReference[];
|
|
113
|
+
/**
|
|
114
|
+
* If set, there might be more results for this list. Use this token to resume the list.
|
|
115
|
+
*/
|
|
116
|
+
nextPageToken?: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Object metadata that can be set at any time.
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
export interface SettableMetadata {
|
|
123
|
+
/**
|
|
124
|
+
* Served as the 'Cache-Control' header on object download.
|
|
125
|
+
*/
|
|
126
|
+
cacheControl?: string | undefined;
|
|
127
|
+
/**
|
|
128
|
+
* Served as the 'Content-Disposition' header on object download.
|
|
129
|
+
*/
|
|
130
|
+
contentDisposition?: string | undefined;
|
|
131
|
+
/**
|
|
132
|
+
* Served as the 'Content-Encoding' header on object download.
|
|
133
|
+
*/
|
|
134
|
+
contentEncoding?: string | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* Served as the 'Content-Language' header on object download.
|
|
137
|
+
*/
|
|
138
|
+
contentLanguage?: string | undefined;
|
|
139
|
+
/**
|
|
140
|
+
* Served as the 'Content-Type' header on object download.
|
|
141
|
+
*/
|
|
142
|
+
contentType?: string | undefined;
|
|
143
|
+
/**
|
|
144
|
+
* Additional user-defined custom metadata.
|
|
145
|
+
*/
|
|
146
|
+
customMetadata?: {
|
|
147
|
+
[key: string]: string;
|
|
148
|
+
} | undefined;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Object metadata that can be set at upload.
|
|
152
|
+
* @public
|
|
153
|
+
*/
|
|
154
|
+
export interface UploadMetadata extends SettableMetadata {
|
|
155
|
+
/**
|
|
156
|
+
* A Base64-encoded MD5 hash of the object being uploaded.
|
|
157
|
+
*/
|
|
158
|
+
md5Hash?: string | undefined;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* The full set of object metadata, including read-only properties.
|
|
162
|
+
* @public
|
|
163
|
+
*/
|
|
164
|
+
export interface FullMetadata extends UploadMetadata {
|
|
165
|
+
/**
|
|
166
|
+
* The bucket this object is contained in.
|
|
167
|
+
*/
|
|
168
|
+
bucket: string;
|
|
169
|
+
/**
|
|
170
|
+
* The full path of this object.
|
|
171
|
+
*/
|
|
172
|
+
fullPath: string;
|
|
173
|
+
/**
|
|
174
|
+
* The object's generation.
|
|
175
|
+
* {@link https://cloud.google.com/storage/docs/metadata#generation-number}
|
|
176
|
+
*/
|
|
177
|
+
generation: string;
|
|
178
|
+
/**
|
|
179
|
+
* The object's metageneration.
|
|
180
|
+
* {@link https://cloud.google.com/storage/docs/metadata#generation-number}
|
|
181
|
+
*/
|
|
182
|
+
metageneration: string;
|
|
183
|
+
/**
|
|
184
|
+
* The short name of this object, which is the last component of the full path.
|
|
185
|
+
* For example, if fullPath is 'full/path/image.png', name is 'image.png'.
|
|
186
|
+
*/
|
|
187
|
+
name: string;
|
|
188
|
+
/**
|
|
189
|
+
* The size of this object, in bytes.
|
|
190
|
+
*/
|
|
191
|
+
size: number;
|
|
192
|
+
/**
|
|
193
|
+
* A date string representing when this object was created.
|
|
194
|
+
*/
|
|
195
|
+
timeCreated: string;
|
|
196
|
+
/**
|
|
197
|
+
* A date string representing when this object was last updated.
|
|
198
|
+
*/
|
|
199
|
+
updated: string;
|
|
200
|
+
/**
|
|
201
|
+
* Tokens to allow access to the download URL.
|
|
202
|
+
*/
|
|
203
|
+
downloadTokens: string[] | undefined;
|
|
204
|
+
/**
|
|
205
|
+
* `StorageReference` associated with this upload.
|
|
206
|
+
*/
|
|
207
|
+
ref?: StorageReference | undefined;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* An event that is triggered on a task.
|
|
211
|
+
* @public
|
|
212
|
+
*/
|
|
213
|
+
export type TaskEvent = 'state_changed';
|
|
214
|
+
/**
|
|
215
|
+
* Represents the current state of a running upload.
|
|
216
|
+
* @public
|
|
217
|
+
*/
|
|
218
|
+
export type TaskState = 'running' | 'paused' | 'success' | 'canceled' | 'error';
|
|
219
|
+
/**
|
|
220
|
+
* A stream observer for Firebase Storage.
|
|
221
|
+
* @public
|
|
222
|
+
*/
|
|
223
|
+
export interface StorageObserver<T> {
|
|
224
|
+
next?: NextFn<T> | null;
|
|
225
|
+
error?: (error: StorageError) => void | null;
|
|
226
|
+
complete?: CompleteFn | null;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Represents the process of uploading an object. Allows you to monitor and
|
|
230
|
+
* manage the upload.
|
|
231
|
+
* @public
|
|
232
|
+
*/
|
|
233
|
+
export interface UploadTask {
|
|
234
|
+
/**
|
|
235
|
+
* Cancels a running task. Has no effect on a complete or failed task.
|
|
236
|
+
* @returns True if the cancel had an effect.
|
|
237
|
+
*/
|
|
238
|
+
cancel(): boolean;
|
|
239
|
+
/**
|
|
240
|
+
* Equivalent to calling `then(null, onRejected)`.
|
|
241
|
+
*/
|
|
242
|
+
catch(onRejected: (error: StorageError) => unknown): Promise<unknown>;
|
|
243
|
+
/**
|
|
244
|
+
* Listens for events on this task.
|
|
245
|
+
*
|
|
246
|
+
* Events have three callback functions (referred to as `next`, `error`, and
|
|
247
|
+
* `complete`).
|
|
248
|
+
*
|
|
249
|
+
* If only the event is passed, a function that can be used to register the
|
|
250
|
+
* callbacks is returned. Otherwise, the callbacks are passed after the event.
|
|
251
|
+
*
|
|
252
|
+
* Callbacks can be passed either as three separate arguments <em>or</em> as the
|
|
253
|
+
* `next`, `error`, and `complete` properties of an object. Any of the three
|
|
254
|
+
* callbacks is optional, as long as at least one is specified. In addition,
|
|
255
|
+
* when you add your callbacks, you get a function back. You can call this
|
|
256
|
+
* function to unregister the associated callbacks.
|
|
257
|
+
*
|
|
258
|
+
* @example **Pass callbacks separately or in an object.**
|
|
259
|
+
* ```javascript
|
|
260
|
+
* var next = function(snapshot) {};
|
|
261
|
+
* var error = function(error) {};
|
|
262
|
+
* var complete = function() {};
|
|
263
|
+
*
|
|
264
|
+
* // The first example.
|
|
265
|
+
* uploadTask.on(
|
|
266
|
+
* firebase.storage.TaskEvent.STATE_CHANGED,
|
|
267
|
+
* next,
|
|
268
|
+
* error,
|
|
269
|
+
* complete);
|
|
270
|
+
*
|
|
271
|
+
* // This is equivalent to the first example.
|
|
272
|
+
* uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, {
|
|
273
|
+
* 'next': next,
|
|
274
|
+
* 'error': error,
|
|
275
|
+
* 'complete': complete
|
|
276
|
+
* });
|
|
277
|
+
*
|
|
278
|
+
* // This is equivalent to the first example.
|
|
279
|
+
* var subscribe = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED);
|
|
280
|
+
* subscribe(next, error, complete);
|
|
281
|
+
*
|
|
282
|
+
* // This is equivalent to the first example.
|
|
283
|
+
* var subscribe = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED);
|
|
284
|
+
* subscribe({
|
|
285
|
+
* 'next': next,
|
|
286
|
+
* 'error': error,
|
|
287
|
+
* 'complete': complete
|
|
288
|
+
* });
|
|
289
|
+
* ```
|
|
290
|
+
*
|
|
291
|
+
* @example **Any callback is optional.**
|
|
292
|
+
* ```javascript
|
|
293
|
+
* // Just listening for completion, this is legal.
|
|
294
|
+
* uploadTask.on(
|
|
295
|
+
* firebase.storage.TaskEvent.STATE_CHANGED,
|
|
296
|
+
* null,
|
|
297
|
+
* null,
|
|
298
|
+
* function() {
|
|
299
|
+
* console.log('upload complete!');
|
|
300
|
+
* });
|
|
301
|
+
*
|
|
302
|
+
* // Just listening for progress/state changes, this is legal.
|
|
303
|
+
* uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, function(snapshot) {
|
|
304
|
+
* var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100;
|
|
305
|
+
* console.log(percent + "% done");
|
|
306
|
+
* });
|
|
307
|
+
*
|
|
308
|
+
* // This is also legal.
|
|
309
|
+
* uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, {
|
|
310
|
+
* 'complete': function() {
|
|
311
|
+
* console.log('upload complete!');
|
|
312
|
+
* }
|
|
313
|
+
* });
|
|
314
|
+
* ```
|
|
315
|
+
*
|
|
316
|
+
* @example **Use the returned function to remove callbacks.**
|
|
317
|
+
* ```javascript
|
|
318
|
+
* var unsubscribe = uploadTask.on(
|
|
319
|
+
* firebase.storage.TaskEvent.STATE_CHANGED,
|
|
320
|
+
* function(snapshot) {
|
|
321
|
+
* var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100;
|
|
322
|
+
* console.log(percent + "% done");
|
|
323
|
+
* // Stop after receiving one update.
|
|
324
|
+
* unsubscribe();
|
|
325
|
+
* });
|
|
326
|
+
*
|
|
327
|
+
* // This code is equivalent to the above.
|
|
328
|
+
* var handle = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED);
|
|
329
|
+
* unsubscribe = handle(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
|
+
*
|
|
337
|
+
* @param event - The type of event to listen for.
|
|
338
|
+
* @param nextOrObserver -
|
|
339
|
+
* The `next` function, which gets called for each item in
|
|
340
|
+
* the event stream, or an observer object with some or all of these three
|
|
341
|
+
* properties (`next`, `error`, `complete`).
|
|
342
|
+
* @param error - A function that gets called with a `StorageError`
|
|
343
|
+
* if the event stream ends due to an error.
|
|
344
|
+
* @param completed - A function that gets called if the
|
|
345
|
+
* event stream ends normally.
|
|
346
|
+
* @returns
|
|
347
|
+
* If only the event argument is passed, returns a function you can use to
|
|
348
|
+
* add callbacks (see the examples above). If more than just the event
|
|
349
|
+
* argument is passed, returns a function you can call to unregister the
|
|
350
|
+
* callbacks.
|
|
351
|
+
*/
|
|
352
|
+
on(event: TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError) => unknown) | null, complete?: Unsubscribe | null): Unsubscribe | Subscribe<UploadTaskSnapshot>;
|
|
353
|
+
/**
|
|
354
|
+
* Pauses a currently running task. Has no effect on a paused or failed task.
|
|
355
|
+
* @returns True if the operation took effect, false if ignored.
|
|
356
|
+
*/
|
|
357
|
+
pause(): boolean;
|
|
358
|
+
/**
|
|
359
|
+
* Resumes a paused task. Has no effect on a currently running or failed task.
|
|
360
|
+
* @returns True if the operation took effect, false if ignored.
|
|
361
|
+
*/
|
|
362
|
+
resume(): boolean;
|
|
363
|
+
/**
|
|
364
|
+
* A snapshot of the current task state.
|
|
365
|
+
*/
|
|
366
|
+
snapshot: UploadTaskSnapshot;
|
|
367
|
+
/**
|
|
368
|
+
* This object behaves like a Promise, and resolves with its snapshot data
|
|
369
|
+
* when the upload completes.
|
|
370
|
+
* @param onFulfilled - The fulfillment callback. Promise chaining works as normal.
|
|
371
|
+
* @param onRejected - The rejection callback.
|
|
372
|
+
*/
|
|
373
|
+
then(onFulfilled?: ((snapshot: UploadTaskSnapshot) => unknown) | null, onRejected?: ((error: StorageError) => unknown) | null): Promise<unknown>;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Holds data about the current state of the upload task.
|
|
377
|
+
* @public
|
|
378
|
+
*/
|
|
379
|
+
export interface UploadTaskSnapshot {
|
|
380
|
+
/**
|
|
381
|
+
* The number of bytes that have been successfully uploaded so far.
|
|
382
|
+
*/
|
|
383
|
+
bytesTransferred: number;
|
|
384
|
+
/**
|
|
385
|
+
* Before the upload completes, contains the metadata sent to the server.
|
|
386
|
+
* After the upload completes, contains the metadata sent back from the server.
|
|
387
|
+
*/
|
|
388
|
+
metadata: FullMetadata;
|
|
389
|
+
/**
|
|
390
|
+
* The reference that spawned this snapshot's upload task.
|
|
391
|
+
*/
|
|
392
|
+
ref: StorageReference;
|
|
393
|
+
/**
|
|
394
|
+
* The current state of the task.
|
|
395
|
+
*/
|
|
396
|
+
state: TaskState;
|
|
397
|
+
/**
|
|
398
|
+
* The task of which this is a snapshot.
|
|
399
|
+
*/
|
|
400
|
+
task: UploadTask;
|
|
401
|
+
/**
|
|
402
|
+
* The total number of bytes to be uploaded.
|
|
403
|
+
*/
|
|
404
|
+
totalBytes: number;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Result returned from a non-resumable upload.
|
|
408
|
+
* @public
|
|
409
|
+
*/
|
|
410
|
+
export interface UploadResult {
|
|
411
|
+
/**
|
|
412
|
+
* Contains the metadata sent back from the server.
|
|
413
|
+
*/
|
|
414
|
+
readonly metadata: FullMetadata;
|
|
415
|
+
/**
|
|
416
|
+
* The reference that spawned this upload.
|
|
417
|
+
*/
|
|
418
|
+
readonly ref: StorageReference;
|
|
419
|
+
}
|
|
420
|
+
declare module '@firebase/component' {
|
|
421
|
+
interface NameServiceMapping {
|
|
422
|
+
'storage': FirebaseStorage;
|
|
423
|
+
}
|
|
424
|
+
}
|