@firebase/storage 0.8.4-canary.31bd6f27f → 0.8.4-canary.dbfe09e9d
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 +1 -1
- package/dist/index.esm2017.js +1 -1
- package/dist/index.esm5.js +1 -1
- package/dist/{index.cjs.js → index.node.cjs.js} +2 -2
- package/dist/index.node.cjs.js.map +1 -0
- package/dist/node-esm/index.node.esm.js +3351 -0
- package/dist/node-esm/index.node.esm.js.map +1 -0
- package/dist/node-esm/package.json +1 -0
- package/dist/node-esm/src/api.browser.d.ts +17 -0
- package/dist/node-esm/src/api.d.ts +184 -0
- package/dist/node-esm/src/api.node.d.ts +17 -0
- package/dist/node-esm/src/constants.d.ts +20 -0
- package/dist/node-esm/src/implementation/async.d.ts +22 -0
- package/dist/node-esm/src/implementation/backoff.d.ts +37 -0
- package/dist/node-esm/src/implementation/blob.d.ts +34 -0
- package/dist/node-esm/src/implementation/connection.d.ts +47 -0
- package/dist/node-esm/src/implementation/constants.d.ts +44 -0
- package/dist/node-esm/src/implementation/error.d.ts +105 -0
- package/dist/node-esm/src/implementation/failrequest.d.ts +29 -0
- package/dist/node-esm/src/implementation/fs.d.ts +17 -0
- package/dist/node-esm/src/implementation/json.d.ts +7 -0
- package/dist/node-esm/src/implementation/list.d.ts +19 -0
- package/dist/node-esm/src/implementation/location.d.ts +32 -0
- package/dist/node-esm/src/implementation/metadata.d.ts +40 -0
- package/dist/node-esm/src/implementation/observer.d.ts +47 -0
- package/dist/node-esm/src/implementation/path.d.ts +31 -0
- package/dist/node-esm/src/implementation/request.d.ts +47 -0
- package/dist/node-esm/src/implementation/requestinfo.d.ts +65 -0
- package/dist/node-esm/src/implementation/requests.d.ts +83 -0
- package/dist/node-esm/src/implementation/string.d.ts +73 -0
- package/dist/node-esm/src/implementation/taskenums.d.ts +77 -0
- package/dist/node-esm/src/implementation/type.d.ts +23 -0
- package/dist/node-esm/src/implementation/url.d.ts +22 -0
- package/dist/node-esm/src/index.d.ts +7 -0
- package/dist/node-esm/src/index.node.d.ts +7 -0
- package/dist/node-esm/src/list.d.ts +41 -0
- package/dist/node-esm/src/metadata.d.ts +27 -0
- package/dist/node-esm/src/platform/base64.d.ts +20 -0
- package/dist/node-esm/src/platform/browser/base64.d.ts +19 -0
- package/dist/node-esm/src/platform/browser/connection.d.ts +39 -0
- package/dist/node-esm/src/platform/connection.d.ts +19 -0
- package/dist/node-esm/src/platform/node/base64.d.ts +19 -0
- package/dist/node-esm/src/platform/node/connection.d.ts +45 -0
- package/dist/node-esm/src/public-types.d.ts +433 -0
- package/dist/node-esm/src/reference.d.ts +196 -0
- package/dist/node-esm/src/service.d.ts +130 -0
- package/dist/node-esm/src/task.d.ts +143 -0
- package/dist/node-esm/test/browser/blob.test.d.ts +17 -0
- package/dist/node-esm/test/browser/connection.test.d.ts +17 -0
- package/dist/node-esm/test/integration/integration.test.d.ts +20 -0
- package/dist/node-esm/test/unit/connection.d.ts +46 -0
- package/dist/node-esm/test/unit/connection.test.d.ts +17 -0
- package/dist/node-esm/test/unit/index.test.d.ts +4 -0
- package/dist/node-esm/test/unit/location.test.d.ts +1 -0
- package/dist/node-esm/test/unit/reference.test.d.ts +1 -0
- package/dist/node-esm/test/unit/request.test.d.ts +1 -0
- package/dist/node-esm/test/unit/requests.test.d.ts +1 -0
- package/dist/node-esm/test/unit/service.test.d.ts +1 -0
- package/dist/node-esm/test/unit/string.test.d.ts +1 -0
- package/dist/node-esm/test/unit/task.test.d.ts +1 -0
- package/dist/node-esm/test/unit/testshared.d.ts +47 -0
- package/package.json +17 -7
- package/dist/index.cjs.js.map +0 -1
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 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 } from '@firebase/app';
|
|
18
|
+
import { StorageReference, FirebaseStorage, UploadResult, ListOptions, ListResult, UploadTask, SettableMetadata, UploadMetadata, FullMetadata } from './public-types';
|
|
19
|
+
import { Reference } from './reference';
|
|
20
|
+
import { EmulatorMockTokenOptions } from '@firebase/util';
|
|
21
|
+
import { StringFormat } from './implementation/string';
|
|
22
|
+
export { EmulatorMockTokenOptions } from '@firebase/util';
|
|
23
|
+
/**
|
|
24
|
+
* Public types.
|
|
25
|
+
*/
|
|
26
|
+
export * from './public-types';
|
|
27
|
+
export { Location as _Location } from './implementation/location';
|
|
28
|
+
export { UploadTask as _UploadTask } from './task';
|
|
29
|
+
export type { Reference as _Reference } from './reference';
|
|
30
|
+
export type { FirebaseStorageImpl as _FirebaseStorageImpl } from './service';
|
|
31
|
+
export { FbsBlob as _FbsBlob } from './implementation/blob';
|
|
32
|
+
export { dataFromString as _dataFromString } from './implementation/string';
|
|
33
|
+
export { invalidRootOperation as _invalidRootOperation, invalidArgument as _invalidArgument } from './implementation/error';
|
|
34
|
+
export { TaskEvent as _TaskEvent, TaskState as _TaskState } from './implementation/taskenums';
|
|
35
|
+
export { StringFormat };
|
|
36
|
+
/**
|
|
37
|
+
* Uploads data to this object's location.
|
|
38
|
+
* The upload is not resumable.
|
|
39
|
+
* @public
|
|
40
|
+
* @param ref - {@link StorageReference} where data should be uploaded.
|
|
41
|
+
* @param data - The data to upload.
|
|
42
|
+
* @param metadata - Metadata for the data to upload.
|
|
43
|
+
* @returns A Promise containing an UploadResult
|
|
44
|
+
*/
|
|
45
|
+
export declare function uploadBytes(ref: StorageReference, data: Blob | Uint8Array | ArrayBuffer, metadata?: UploadMetadata): Promise<UploadResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Uploads a string to this object's location.
|
|
48
|
+
* The upload is not resumable.
|
|
49
|
+
* @public
|
|
50
|
+
* @param ref - {@link StorageReference} where string should be uploaded.
|
|
51
|
+
* @param value - The string to upload.
|
|
52
|
+
* @param format - The format of the string to upload.
|
|
53
|
+
* @param metadata - Metadata for the string to upload.
|
|
54
|
+
* @returns A Promise containing an UploadResult
|
|
55
|
+
*/
|
|
56
|
+
export declare function uploadString(ref: StorageReference, value: string, format?: StringFormat, metadata?: UploadMetadata): Promise<UploadResult>;
|
|
57
|
+
/**
|
|
58
|
+
* Uploads data to this object's location.
|
|
59
|
+
* The upload can be paused and resumed, and exposes progress updates.
|
|
60
|
+
* @public
|
|
61
|
+
* @param ref - {@link StorageReference} where data should be uploaded.
|
|
62
|
+
* @param data - The data to upload.
|
|
63
|
+
* @param metadata - Metadata for the data to upload.
|
|
64
|
+
* @returns An UploadTask
|
|
65
|
+
*/
|
|
66
|
+
export declare function uploadBytesResumable(ref: StorageReference, data: Blob | Uint8Array | ArrayBuffer, metadata?: UploadMetadata): UploadTask;
|
|
67
|
+
/**
|
|
68
|
+
* A `Promise` that resolves with the metadata for this object. If this
|
|
69
|
+
* object doesn't exist or metadata cannot be retreived, the promise is
|
|
70
|
+
* rejected.
|
|
71
|
+
* @public
|
|
72
|
+
* @param ref - {@link StorageReference} to get metadata from.
|
|
73
|
+
*/
|
|
74
|
+
export declare function getMetadata(ref: StorageReference): Promise<FullMetadata>;
|
|
75
|
+
/**
|
|
76
|
+
* Updates the metadata for this object.
|
|
77
|
+
* @public
|
|
78
|
+
* @param ref - {@link StorageReference} to update metadata for.
|
|
79
|
+
* @param metadata - The new metadata for the object.
|
|
80
|
+
* Only values that have been explicitly set will be changed. Explicitly
|
|
81
|
+
* setting a value to null will remove the metadata.
|
|
82
|
+
* @returns A `Promise` that resolves with the new metadata for this object.
|
|
83
|
+
*/
|
|
84
|
+
export declare function updateMetadata(ref: StorageReference, metadata: SettableMetadata): Promise<FullMetadata>;
|
|
85
|
+
/**
|
|
86
|
+
* List items (files) and prefixes (folders) under this storage reference.
|
|
87
|
+
*
|
|
88
|
+
* List API is only available for Firebase Rules Version 2.
|
|
89
|
+
*
|
|
90
|
+
* GCS is a key-blob store. Firebase Storage imposes the semantic of '/'
|
|
91
|
+
* delimited folder structure.
|
|
92
|
+
* Refer to GCS's List API if you want to learn more.
|
|
93
|
+
*
|
|
94
|
+
* To adhere to Firebase Rules's Semantics, Firebase Storage does not
|
|
95
|
+
* support objects whose paths end with "/" or contain two consecutive
|
|
96
|
+
* "/"s. Firebase Storage List API will filter these unsupported objects.
|
|
97
|
+
* list() may fail if there are too many unsupported objects in the bucket.
|
|
98
|
+
* @public
|
|
99
|
+
*
|
|
100
|
+
* @param ref - {@link StorageReference} to get list from.
|
|
101
|
+
* @param options - See {@link ListOptions} for details.
|
|
102
|
+
* @returns A `Promise` that resolves with the items and prefixes.
|
|
103
|
+
* `prefixes` contains references to sub-folders and `items`
|
|
104
|
+
* contains references to objects in this folder. `nextPageToken`
|
|
105
|
+
* can be used to get the rest of the results.
|
|
106
|
+
*/
|
|
107
|
+
export declare function list(ref: StorageReference, options?: ListOptions): Promise<ListResult>;
|
|
108
|
+
/**
|
|
109
|
+
* List all items (files) and prefixes (folders) under this storage reference.
|
|
110
|
+
*
|
|
111
|
+
* This is a helper method for calling list() repeatedly until there are
|
|
112
|
+
* no more results. The default pagination size is 1000.
|
|
113
|
+
*
|
|
114
|
+
* Note: The results may not be consistent if objects are changed while this
|
|
115
|
+
* operation is running.
|
|
116
|
+
*
|
|
117
|
+
* Warning: `listAll` may potentially consume too many resources if there are
|
|
118
|
+
* too many results.
|
|
119
|
+
* @public
|
|
120
|
+
* @param ref - {@link StorageReference} to get list from.
|
|
121
|
+
*
|
|
122
|
+
* @returns A `Promise` that resolves with all the items and prefixes under
|
|
123
|
+
* the current storage reference. `prefixes` contains references to
|
|
124
|
+
* sub-directories and `items` contains references to objects in this
|
|
125
|
+
* folder. `nextPageToken` is never returned.
|
|
126
|
+
*/
|
|
127
|
+
export declare function listAll(ref: StorageReference): Promise<ListResult>;
|
|
128
|
+
/**
|
|
129
|
+
* Returns the download URL for the given {@link StorageReference}.
|
|
130
|
+
* @public
|
|
131
|
+
* @param ref - {@link StorageReference} to get the download URL for.
|
|
132
|
+
* @returns A `Promise` that resolves with the download
|
|
133
|
+
* URL for this object.
|
|
134
|
+
*/
|
|
135
|
+
export declare function getDownloadURL(ref: StorageReference): Promise<string>;
|
|
136
|
+
/**
|
|
137
|
+
* Deletes the object at this location.
|
|
138
|
+
* @public
|
|
139
|
+
* @param ref - {@link StorageReference} for object to delete.
|
|
140
|
+
* @returns A `Promise` that resolves if the deletion succeeds.
|
|
141
|
+
*/
|
|
142
|
+
export declare function deleteObject(ref: StorageReference): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* Returns a {@link StorageReference} for the given url.
|
|
145
|
+
* @param storage - {@link FirebaseStorage} instance.
|
|
146
|
+
* @param url - URL. If empty, returns root reference.
|
|
147
|
+
* @public
|
|
148
|
+
*/
|
|
149
|
+
export declare function ref(storage: FirebaseStorage, url?: string): StorageReference;
|
|
150
|
+
/**
|
|
151
|
+
* Returns a {@link StorageReference} for the given path in the
|
|
152
|
+
* default bucket.
|
|
153
|
+
* @param storageOrRef - {@link FirebaseStorage} or {@link StorageReference}.
|
|
154
|
+
* @param pathOrUrlStorage - path. If empty, returns root reference (if {@link FirebaseStorage}
|
|
155
|
+
* instance provided) or returns same reference (if {@link StorageReference} provided).
|
|
156
|
+
* @public
|
|
157
|
+
*/
|
|
158
|
+
export declare function ref(storageOrRef: FirebaseStorage | StorageReference, path?: string): StorageReference;
|
|
159
|
+
/**
|
|
160
|
+
* @internal
|
|
161
|
+
*/
|
|
162
|
+
export declare function _getChild(ref: StorageReference, childPath: string): Reference;
|
|
163
|
+
/**
|
|
164
|
+
* Gets a {@link FirebaseStorage} instance for the given Firebase app.
|
|
165
|
+
* @public
|
|
166
|
+
* @param app - Firebase app to get {@link FirebaseStorage} instance for.
|
|
167
|
+
* @param bucketUrl - The gs:// url to your Firebase Storage Bucket.
|
|
168
|
+
* If not passed, uses the app's default Storage Bucket.
|
|
169
|
+
* @returns A {@link FirebaseStorage} instance.
|
|
170
|
+
*/
|
|
171
|
+
export declare function getStorage(app?: FirebaseApp, bucketUrl?: string): FirebaseStorage;
|
|
172
|
+
/**
|
|
173
|
+
* Modify this {@link FirebaseStorage} instance to communicate with the Cloud Storage emulator.
|
|
174
|
+
*
|
|
175
|
+
* @param storage - The {@link FirebaseStorage} instance
|
|
176
|
+
* @param host - The emulator host (ex: localhost)
|
|
177
|
+
* @param port - The emulator port (ex: 5001)
|
|
178
|
+
* @param options - Emulator options. `options.mockUserToken` is the mock auth
|
|
179
|
+
* token to use for unit testing Security Rules.
|
|
180
|
+
* @public
|
|
181
|
+
*/
|
|
182
|
+
export declare function connectStorageEmulator(storage: FirebaseStorage, host: string, port: number, options?: {
|
|
183
|
+
mockUserToken?: EmulatorMockTokenOptions | string;
|
|
184
|
+
}): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 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
|
+
/**
|
|
18
|
+
* Type constant for Firebase Storage.
|
|
19
|
+
*/
|
|
20
|
+
export declare const STORAGE_TYPE = "storage";
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
/**
|
|
18
|
+
* Returns a function that invokes f with its arguments asynchronously as a
|
|
19
|
+
* microtask, i.e. as soon as possible after the current script returns back
|
|
20
|
+
* into browser code.
|
|
21
|
+
*/
|
|
22
|
+
export declare function async(f: Function): Function;
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
/**
|
|
18
|
+
* @fileoverview Provides a method for running a function with exponential
|
|
19
|
+
* backoff.
|
|
20
|
+
*/
|
|
21
|
+
declare type id = (p1: boolean) => void;
|
|
22
|
+
export { id };
|
|
23
|
+
/**
|
|
24
|
+
* @param f May be invoked
|
|
25
|
+
* before the function returns.
|
|
26
|
+
* @param callback Get all the arguments passed to the function
|
|
27
|
+
* passed to f, including the initial boolean.
|
|
28
|
+
*/
|
|
29
|
+
export declare function start(f: (p1: (success: boolean) => void, canceled: boolean) => void, callback: (...args: any[]) => unknown, timeout: number): id;
|
|
30
|
+
/**
|
|
31
|
+
* Stops the retry loop from repeating.
|
|
32
|
+
* If the function is currently "in between" retries, it is invoked immediately
|
|
33
|
+
* with the second parameter as "true". Otherwise, it will be invoked once more
|
|
34
|
+
* after the current invocation finishes iff the current invocation would have
|
|
35
|
+
* triggered another retry.
|
|
36
|
+
*/
|
|
37
|
+
export declare function stop(id: id): void;
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
/**
|
|
18
|
+
* @param opt_elideCopy - If true, doesn't copy mutable input data
|
|
19
|
+
* (e.g. Uint8Arrays). Pass true only if you know the objects will not be
|
|
20
|
+
* modified after this blob's construction.
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export declare class FbsBlob {
|
|
25
|
+
private data_;
|
|
26
|
+
private size_;
|
|
27
|
+
private type_;
|
|
28
|
+
constructor(data: Blob | Uint8Array | ArrayBuffer, elideCopy?: boolean);
|
|
29
|
+
size(): number;
|
|
30
|
+
type(): string;
|
|
31
|
+
slice(startByte: number, endByte: number): FbsBlob | null;
|
|
32
|
+
static getBlob(...args: Array<string | FbsBlob>): FbsBlob | null;
|
|
33
|
+
uploadData(): Blob | Uint8Array;
|
|
34
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
/** Network headers */
|
|
18
|
+
export declare type Headers = Record<string, string>;
|
|
19
|
+
/**
|
|
20
|
+
* A lightweight wrapper around XMLHttpRequest with a
|
|
21
|
+
* goog.net.XhrIo-like interface.
|
|
22
|
+
*/
|
|
23
|
+
export interface Connection {
|
|
24
|
+
/**
|
|
25
|
+
* This method should never reject. In case of encountering an error, set an error code internally which can be accessed
|
|
26
|
+
* by calling getErrorCode() by callers.
|
|
27
|
+
*/
|
|
28
|
+
send(url: string, method: string, body?: ArrayBufferView | Blob | string | null, headers?: Headers): Promise<void>;
|
|
29
|
+
getErrorCode(): ErrorCode;
|
|
30
|
+
getStatus(): number;
|
|
31
|
+
getResponseText(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Abort the request.
|
|
34
|
+
*/
|
|
35
|
+
abort(): void;
|
|
36
|
+
getResponseHeader(header: string): string | null;
|
|
37
|
+
addUploadProgressListener(listener: (p1: ProgressEvent) => void): void;
|
|
38
|
+
removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Error codes for requests made by the the XhrIo wrapper.
|
|
42
|
+
*/
|
|
43
|
+
export declare enum ErrorCode {
|
|
44
|
+
NO_ERROR = 0,
|
|
45
|
+
NETWORK_ERROR = 1,
|
|
46
|
+
ABORT = 2
|
|
47
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
/**
|
|
18
|
+
* @fileoverview Constants used in the Firebase Storage library.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Domain name for firebase storage.
|
|
22
|
+
*/
|
|
23
|
+
export declare const DEFAULT_HOST = "firebasestorage.googleapis.com";
|
|
24
|
+
/**
|
|
25
|
+
* The key in Firebase config json for the storage bucket.
|
|
26
|
+
*/
|
|
27
|
+
export declare const CONFIG_STORAGE_BUCKET_KEY = "storageBucket";
|
|
28
|
+
/**
|
|
29
|
+
* 2 minutes
|
|
30
|
+
*
|
|
31
|
+
* The timeout for all operations except upload.
|
|
32
|
+
*/
|
|
33
|
+
export declare const DEFAULT_MAX_OPERATION_RETRY_TIME: number;
|
|
34
|
+
/**
|
|
35
|
+
* 10 minutes
|
|
36
|
+
*
|
|
37
|
+
* The timeout for upload.
|
|
38
|
+
*/
|
|
39
|
+
export declare const DEFAULT_MAX_UPLOAD_RETRY_TIME: number;
|
|
40
|
+
/**
|
|
41
|
+
* This is the value of Number.MIN_SAFE_INTEGER, which is not well supported
|
|
42
|
+
* enough for us to use it directly.
|
|
43
|
+
*/
|
|
44
|
+
export declare const MIN_SAFE_INTEGER = -9007199254740991;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { FirebaseError } from '@firebase/util';
|
|
2
|
+
/**
|
|
3
|
+
* An error returned by the Firebase Storage SDK.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export declare class StorageError extends FirebaseError {
|
|
7
|
+
private readonly _baseMessage;
|
|
8
|
+
/**
|
|
9
|
+
* Stores custom error data unque to StorageError.
|
|
10
|
+
*/
|
|
11
|
+
customData: {
|
|
12
|
+
serverResponse: string | null;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* @param code - A StorageErrorCode string to be prefixed with 'storage/' and
|
|
16
|
+
* added to the end of the message.
|
|
17
|
+
* @param message - Error message.
|
|
18
|
+
*/
|
|
19
|
+
constructor(code: StorageErrorCode, message: string);
|
|
20
|
+
/**
|
|
21
|
+
* Compares a StorageErrorCode against this error's code, filtering out the prefix.
|
|
22
|
+
*/
|
|
23
|
+
_codeEquals(code: StorageErrorCode): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Optional response message that was added by the server.
|
|
26
|
+
*/
|
|
27
|
+
get serverResponse(): null | string;
|
|
28
|
+
set serverResponse(serverResponse: string | null);
|
|
29
|
+
}
|
|
30
|
+
export declare const errors: {};
|
|
31
|
+
/**
|
|
32
|
+
* @public
|
|
33
|
+
* Error codes that can be attached to `StorageError`s.
|
|
34
|
+
*/
|
|
35
|
+
export declare const enum StorageErrorCode {
|
|
36
|
+
UNKNOWN = "unknown",
|
|
37
|
+
OBJECT_NOT_FOUND = "object-not-found",
|
|
38
|
+
BUCKET_NOT_FOUND = "bucket-not-found",
|
|
39
|
+
PROJECT_NOT_FOUND = "project-not-found",
|
|
40
|
+
QUOTA_EXCEEDED = "quota-exceeded",
|
|
41
|
+
UNAUTHENTICATED = "unauthenticated",
|
|
42
|
+
UNAUTHORIZED = "unauthorized",
|
|
43
|
+
UNAUTHORIZED_APP = "unauthorized-app",
|
|
44
|
+
RETRY_LIMIT_EXCEEDED = "retry-limit-exceeded",
|
|
45
|
+
INVALID_CHECKSUM = "invalid-checksum",
|
|
46
|
+
CANCELED = "canceled",
|
|
47
|
+
INVALID_EVENT_NAME = "invalid-event-name",
|
|
48
|
+
INVALID_URL = "invalid-url",
|
|
49
|
+
INVALID_DEFAULT_BUCKET = "invalid-default-bucket",
|
|
50
|
+
NO_DEFAULT_BUCKET = "no-default-bucket",
|
|
51
|
+
CANNOT_SLICE_BLOB = "cannot-slice-blob",
|
|
52
|
+
SERVER_FILE_WRONG_SIZE = "server-file-wrong-size",
|
|
53
|
+
NO_DOWNLOAD_URL = "no-download-url",
|
|
54
|
+
INVALID_ARGUMENT = "invalid-argument",
|
|
55
|
+
INVALID_ARGUMENT_COUNT = "invalid-argument-count",
|
|
56
|
+
APP_DELETED = "app-deleted",
|
|
57
|
+
INVALID_ROOT_OPERATION = "invalid-root-operation",
|
|
58
|
+
INVALID_FORMAT = "invalid-format",
|
|
59
|
+
INTERNAL_ERROR = "internal-error",
|
|
60
|
+
UNSUPPORTED_ENVIRONMENT = "unsupported-environment"
|
|
61
|
+
}
|
|
62
|
+
export declare function prependCode(code: StorageErrorCode): string;
|
|
63
|
+
export declare function unknown(): StorageError;
|
|
64
|
+
export declare function objectNotFound(path: string): StorageError;
|
|
65
|
+
export declare function bucketNotFound(bucket: string): StorageError;
|
|
66
|
+
export declare function projectNotFound(project: string): StorageError;
|
|
67
|
+
export declare function quotaExceeded(bucket: string): StorageError;
|
|
68
|
+
export declare function unauthenticated(): StorageError;
|
|
69
|
+
export declare function unauthorizedApp(): StorageError;
|
|
70
|
+
export declare function unauthorized(path: string): StorageError;
|
|
71
|
+
export declare function retryLimitExceeded(): StorageError;
|
|
72
|
+
export declare function invalidChecksum(path: string, checksum: string, calculated: string): StorageError;
|
|
73
|
+
export declare function canceled(): StorageError;
|
|
74
|
+
export declare function invalidEventName(name: string): StorageError;
|
|
75
|
+
export declare function invalidUrl(url: string): StorageError;
|
|
76
|
+
export declare function invalidDefaultBucket(bucket: string): StorageError;
|
|
77
|
+
export declare function noDefaultBucket(): StorageError;
|
|
78
|
+
export declare function cannotSliceBlob(): StorageError;
|
|
79
|
+
export declare function serverFileWrongSize(): StorageError;
|
|
80
|
+
export declare function noDownloadURL(): StorageError;
|
|
81
|
+
/**
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
export declare function invalidArgument(message: string): StorageError;
|
|
85
|
+
export declare function invalidArgumentCount(argMin: number, argMax: number, fnName: string, real: number): StorageError;
|
|
86
|
+
export declare function appDeleted(): StorageError;
|
|
87
|
+
/**
|
|
88
|
+
* @param name - The name of the operation that was invalid.
|
|
89
|
+
*
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
export declare function invalidRootOperation(name: string): StorageError;
|
|
93
|
+
/**
|
|
94
|
+
* @param format - The format that was not valid.
|
|
95
|
+
* @param message - A message describing the format violation.
|
|
96
|
+
*/
|
|
97
|
+
export declare function invalidFormat(format: string, message: string): StorageError;
|
|
98
|
+
/**
|
|
99
|
+
* @param message - A message describing the internal error.
|
|
100
|
+
*/
|
|
101
|
+
export declare function unsupportedEnvironment(message: string): StorageError;
|
|
102
|
+
/**
|
|
103
|
+
* @param message - A message describing the internal error.
|
|
104
|
+
*/
|
|
105
|
+
export declare function internalError(message: string): StorageError;
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { StorageError } from './error';
|
|
18
|
+
import { Request } from './request';
|
|
19
|
+
/**
|
|
20
|
+
* A request whose promise always fails.
|
|
21
|
+
*/
|
|
22
|
+
export declare class FailRequest<T> implements Request<T> {
|
|
23
|
+
promise_: Promise<T>;
|
|
24
|
+
constructor(error: StorageError);
|
|
25
|
+
/** @inheritDoc */
|
|
26
|
+
getPromise(): Promise<T>;
|
|
27
|
+
/** @inheritDoc */
|
|
28
|
+
cancel(_appDelete?: boolean): void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Concatenates one or more values together and converts them to a Blob.
|
|
3
|
+
*
|
|
4
|
+
* @param args The values that will make up the resulting blob.
|
|
5
|
+
* @return The blob.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getBlob(...args: Array<string | Blob | ArrayBuffer>): Blob;
|
|
8
|
+
/**
|
|
9
|
+
* Slices the blob. The returned blob contains data from the start byte
|
|
10
|
+
* (inclusive) till the end byte (exclusive). Negative indices cannot be used.
|
|
11
|
+
*
|
|
12
|
+
* @param blob The blob to be sliced.
|
|
13
|
+
* @param start Index of the starting byte.
|
|
14
|
+
* @param end Index of the ending byte.
|
|
15
|
+
* @return The blob slice or null if not supported.
|
|
16
|
+
*/
|
|
17
|
+
export declare function sliceBlob(blob: Blob, start: number, end: number): Blob | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
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 { ListResult } from '../list';
|
|
18
|
+
import { FirebaseStorageImpl } from '../service';
|
|
19
|
+
export declare function fromResponseString(service: FirebaseStorageImpl, bucket: string, resourceString: string): ListResult | null;
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
/**
|
|
18
|
+
* Firebase Storage location data.
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export declare class Location {
|
|
23
|
+
readonly bucket: string;
|
|
24
|
+
private path_;
|
|
25
|
+
constructor(bucket: string, path: string);
|
|
26
|
+
get path(): string;
|
|
27
|
+
get isRoot(): boolean;
|
|
28
|
+
fullServerUrl(): string;
|
|
29
|
+
bucketOnlyServerUrl(): string;
|
|
30
|
+
static makeFromBucketSpec(bucketString: string, host: string): Location;
|
|
31
|
+
static makeFromUrl(url: string, host: string): Location;
|
|
32
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
/**
|
|
18
|
+
* @fileoverview Documentation for the metadata format
|
|
19
|
+
*/
|
|
20
|
+
import { Metadata } from '../metadata';
|
|
21
|
+
import { FirebaseStorageImpl } from '../service';
|
|
22
|
+
export declare function noXform_<T>(metadata: Metadata, value: T): T;
|
|
23
|
+
declare class Mapping<T> {
|
|
24
|
+
server: string;
|
|
25
|
+
local: string;
|
|
26
|
+
writable: boolean;
|
|
27
|
+
xform: (p1: Metadata, p2?: T) => T | undefined;
|
|
28
|
+
constructor(server: string, local?: string | null, writable?: boolean, xform?: ((p1: Metadata, p2?: T) => T | undefined) | null);
|
|
29
|
+
}
|
|
30
|
+
declare type Mappings = Array<Mapping<string> | Mapping<number>>;
|
|
31
|
+
export { Mappings };
|
|
32
|
+
export declare function xformPath(fullPath: string | undefined): string | undefined;
|
|
33
|
+
export declare function getMappings(): Mappings;
|
|
34
|
+
export declare function addRef(metadata: Metadata, service: FirebaseStorageImpl): void;
|
|
35
|
+
export declare function fromResource(service: FirebaseStorageImpl, resource: {
|
|
36
|
+
[name: string]: unknown;
|
|
37
|
+
}, mappings: Mappings): Metadata;
|
|
38
|
+
export declare function fromResourceString(service: FirebaseStorageImpl, resourceString: string, mappings: Mappings): Metadata | null;
|
|
39
|
+
export declare function downloadUrlFromResourceString(metadata: Metadata, resourceString: string, host: string, protocol: string): string | null;
|
|
40
|
+
export declare function toResourceString(metadata: Partial<Metadata>, mappings: Mappings): string;
|