@firebase/storage 0.8.6 → 0.8.7-canary.ce39a1a07
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/CHANGELOG.md +6 -0
- package/dist/index.browser.cjs.js +215 -31
- package/dist/index.browser.cjs.js.map +1 -1
- package/dist/index.esm2017.js +194 -32
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +213 -32
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +262 -51
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/node-esm/index.node.esm.js +206 -52
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/api.browser.d.ts +32 -1
- package/dist/node-esm/src/api.d.ts +15 -0
- package/dist/node-esm/src/api.node.d.ts +32 -1
- package/dist/node-esm/src/implementation/connection.d.ts +14 -4
- package/dist/node-esm/src/implementation/request.d.ts +5 -5
- package/dist/node-esm/src/implementation/requestinfo.d.ts +14 -6
- package/dist/node-esm/src/implementation/requests.d.ts +17 -16
- package/dist/node-esm/src/platform/browser/connection.d.ts +24 -7
- package/dist/node-esm/src/platform/connection.d.ts +6 -2
- package/dist/node-esm/src/platform/node/connection.d.ts +30 -14
- package/dist/node-esm/src/reference.d.ts +13 -0
- package/dist/node-esm/src/service.d.ts +3 -3
- package/dist/node-esm/test/integration/integration.test.d.ts +4 -0
- package/dist/node-esm/test/{unit → node}/connection.test.d.ts +0 -0
- package/dist/{test/unit/connection.test.d.ts → node-esm/test/node/stream.test.d.ts} +0 -0
- package/dist/node-esm/test/unit/connection.d.ts +4 -3
- package/dist/node-esm/test/unit/testshared.d.ts +2 -2
- package/dist/src/api.browser.d.ts +32 -1
- package/dist/src/api.d.ts +15 -0
- package/dist/src/api.node.d.ts +32 -1
- package/dist/src/implementation/connection.d.ts +14 -4
- package/dist/src/implementation/request.d.ts +5 -5
- package/dist/src/implementation/requestinfo.d.ts +14 -6
- package/dist/src/implementation/requests.d.ts +17 -16
- package/dist/src/platform/browser/connection.d.ts +24 -7
- package/dist/src/platform/connection.d.ts +6 -2
- package/dist/src/platform/node/connection.d.ts +30 -14
- package/dist/src/reference.d.ts +13 -0
- package/dist/src/service.d.ts +3 -3
- package/dist/storage-public.d.ts +46 -0
- package/dist/storage.d.ts +80 -11
- package/dist/test/integration/integration.test.d.ts +4 -0
- package/dist/test/node/connection.test.d.ts +17 -0
- package/dist/test/node/stream.test.d.ts +17 -0
- package/dist/test/unit/connection.d.ts +4 -3
- package/dist/test/unit/testshared.d.ts +2 -2
- package/package.json +6 -6
|
@@ -337,7 +337,9 @@ callback, timeout) {
|
|
|
337
337
|
// Would type this as "number" but that doesn't work for Node so ¯\_(ツ)_/¯
|
|
338
338
|
// TODO: find a way to exclude Node type definition for storage because storage only works in browser
|
|
339
339
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
340
|
-
let
|
|
340
|
+
let retryTimeoutId = null;
|
|
341
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
342
|
+
let globalTimeoutId = null;
|
|
341
343
|
let hitTimeout = false;
|
|
342
344
|
let cancelState = 0;
|
|
343
345
|
function canceled() {
|
|
@@ -351,21 +353,29 @@ callback, timeout) {
|
|
|
351
353
|
}
|
|
352
354
|
}
|
|
353
355
|
function callWithDelay(millis) {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
+
retryTimeoutId = setTimeout(() => {
|
|
357
|
+
retryTimeoutId = null;
|
|
356
358
|
f(handler, canceled());
|
|
357
359
|
}, millis);
|
|
358
360
|
}
|
|
361
|
+
function clearGlobalTimeout() {
|
|
362
|
+
if (globalTimeoutId) {
|
|
363
|
+
clearTimeout(globalTimeoutId);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
359
366
|
function handler(success, ...args) {
|
|
360
367
|
if (triggeredCallback) {
|
|
368
|
+
clearGlobalTimeout();
|
|
361
369
|
return;
|
|
362
370
|
}
|
|
363
371
|
if (success) {
|
|
372
|
+
clearGlobalTimeout();
|
|
364
373
|
triggerCallback.call(null, success, ...args);
|
|
365
374
|
return;
|
|
366
375
|
}
|
|
367
376
|
const mustStop = canceled() || hitTimeout;
|
|
368
377
|
if (mustStop) {
|
|
378
|
+
clearGlobalTimeout();
|
|
369
379
|
triggerCallback.call(null, success, ...args);
|
|
370
380
|
return;
|
|
371
381
|
}
|
|
@@ -389,14 +399,15 @@ callback, timeout) {
|
|
|
389
399
|
return;
|
|
390
400
|
}
|
|
391
401
|
stopped = true;
|
|
402
|
+
clearGlobalTimeout();
|
|
392
403
|
if (triggeredCallback) {
|
|
393
404
|
return;
|
|
394
405
|
}
|
|
395
|
-
if (
|
|
406
|
+
if (retryTimeoutId !== null) {
|
|
396
407
|
if (!wasTimeout) {
|
|
397
408
|
cancelState = 2;
|
|
398
409
|
}
|
|
399
|
-
clearTimeout(
|
|
410
|
+
clearTimeout(retryTimeoutId);
|
|
400
411
|
callWithDelay(0);
|
|
401
412
|
}
|
|
402
413
|
else {
|
|
@@ -406,7 +417,7 @@ callback, timeout) {
|
|
|
406
417
|
}
|
|
407
418
|
}
|
|
408
419
|
callWithDelay(0);
|
|
409
|
-
setTimeout(() => {
|
|
420
|
+
globalTimeoutId = setTimeout(() => {
|
|
410
421
|
hitTimeout = true;
|
|
411
422
|
stop(true);
|
|
412
423
|
}, timeout);
|
|
@@ -546,6 +557,14 @@ var ErrorCode;
|
|
|
546
557
|
* See the License for the specific language governing permissions and
|
|
547
558
|
* limitations under the License.
|
|
548
559
|
*/
|
|
560
|
+
/**
|
|
561
|
+
* Handles network logic for all Storage Requests, including error reporting and
|
|
562
|
+
* retries with backoff.
|
|
563
|
+
*
|
|
564
|
+
* @param I - the type of the backend's network response.
|
|
565
|
+
* @param - O the output type used by the rest of the SDK. The conversion
|
|
566
|
+
* happens in the specified `callback_`.
|
|
567
|
+
*/
|
|
549
568
|
class NetworkRequest {
|
|
550
569
|
constructor(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, connectionFactory_) {
|
|
551
570
|
this.url_ = url_;
|
|
@@ -622,7 +641,7 @@ class NetworkRequest {
|
|
|
622
641
|
const connection = status.connection;
|
|
623
642
|
if (status.wasSuccessCode) {
|
|
624
643
|
try {
|
|
625
|
-
const result = this.callback_(connection, connection.
|
|
644
|
+
const result = this.callback_(connection, connection.getResponse());
|
|
626
645
|
if (isJustDef(result)) {
|
|
627
646
|
resolve(result);
|
|
628
647
|
}
|
|
@@ -637,7 +656,7 @@ class NetworkRequest {
|
|
|
637
656
|
else {
|
|
638
657
|
if (connection !== null) {
|
|
639
658
|
const err = unknown();
|
|
640
|
-
err.serverResponse = connection.
|
|
659
|
+
err.serverResponse = connection.getErrorText();
|
|
641
660
|
if (this.errorCallback_) {
|
|
642
661
|
reject(this.errorCallback_(connection, err));
|
|
643
662
|
}
|
|
@@ -768,7 +787,7 @@ function getBlobBuilder() {
|
|
|
768
787
|
* @param args The values that will make up the resulting blob.
|
|
769
788
|
* @return The blob.
|
|
770
789
|
*/
|
|
771
|
-
function getBlob(...args) {
|
|
790
|
+
function getBlob$1(...args) {
|
|
772
791
|
const BlobBuilder = getBlobBuilder();
|
|
773
792
|
if (BlobBuilder !== undefined) {
|
|
774
793
|
const bb = new BlobBuilder();
|
|
@@ -1123,7 +1142,7 @@ class FbsBlob {
|
|
|
1123
1142
|
return val;
|
|
1124
1143
|
}
|
|
1125
1144
|
});
|
|
1126
|
-
return new FbsBlob(getBlob.apply(null, blobby));
|
|
1145
|
+
return new FbsBlob(getBlob$1.apply(null, blobby));
|
|
1127
1146
|
}
|
|
1128
1147
|
else {
|
|
1129
1148
|
const uint8Arrays = args.map((val) => {
|
|
@@ -1445,6 +1464,12 @@ function fromResponseString(service, bucket, resourceString) {
|
|
|
1445
1464
|
return fromBackendResponse(service, bucket, resource);
|
|
1446
1465
|
}
|
|
1447
1466
|
|
|
1467
|
+
/**
|
|
1468
|
+
* Contains a fully specified request.
|
|
1469
|
+
*
|
|
1470
|
+
* @param I - the type of the backend's network response.
|
|
1471
|
+
* @param O - the output response type used by the rest of the SDK.
|
|
1472
|
+
*/
|
|
1448
1473
|
class RequestInfo {
|
|
1449
1474
|
constructor(url, method,
|
|
1450
1475
|
/**
|
|
@@ -1528,7 +1553,7 @@ function sharedErrorHandler(location) {
|
|
|
1528
1553
|
if (
|
|
1529
1554
|
// This exact message string is the only consistent part of the
|
|
1530
1555
|
// server's error response that identifies it as an App Check error.
|
|
1531
|
-
xhr.
|
|
1556
|
+
xhr.getErrorText().includes('Firebase App Check token is invalid')) {
|
|
1532
1557
|
newErr = unauthorizedApp();
|
|
1533
1558
|
}
|
|
1534
1559
|
else {
|
|
@@ -1600,6 +1625,19 @@ function list$2(service, location, delimiter, pageToken, maxResults) {
|
|
|
1600
1625
|
requestInfo.errorHandler = sharedErrorHandler(location);
|
|
1601
1626
|
return requestInfo;
|
|
1602
1627
|
}
|
|
1628
|
+
function getBytes$1(service, location, maxDownloadSizeBytes) {
|
|
1629
|
+
const urlPart = location.fullServerUrl();
|
|
1630
|
+
const url = makeUrl(urlPart, service.host, service._protocol) + '?alt=media';
|
|
1631
|
+
const method = 'GET';
|
|
1632
|
+
const timeout = service.maxOperationRetryTime;
|
|
1633
|
+
const requestInfo = new RequestInfo(url, method, (_, data) => data, timeout);
|
|
1634
|
+
requestInfo.errorHandler = objectErrorHandler(location);
|
|
1635
|
+
if (maxDownloadSizeBytes !== undefined) {
|
|
1636
|
+
requestInfo.headers['Range'] = `bytes=0-${maxDownloadSizeBytes}`;
|
|
1637
|
+
requestInfo.successCodes = [200 /* OK */, 206 /* Partial Content */];
|
|
1638
|
+
}
|
|
1639
|
+
return requestInfo;
|
|
1640
|
+
}
|
|
1603
1641
|
function getDownloadUrl(service, location, mappings) {
|
|
1604
1642
|
const urlPart = location.fullServerUrl();
|
|
1605
1643
|
const url = makeUrl(urlPart, service.host, service._protocol);
|
|
@@ -2006,7 +2044,7 @@ function async(f) {
|
|
|
2006
2044
|
* limitations under the License.
|
|
2007
2045
|
*/
|
|
2008
2046
|
/** An override for the text-based Connection. Used in tests. */
|
|
2009
|
-
let
|
|
2047
|
+
let textFactoryOverride = null;
|
|
2010
2048
|
/**
|
|
2011
2049
|
* Network layer that works in Node.
|
|
2012
2050
|
*
|
|
@@ -2015,31 +2053,33 @@ let connectionFactoryOverride = null;
|
|
|
2015
2053
|
*/
|
|
2016
2054
|
class FetchConnection {
|
|
2017
2055
|
constructor() {
|
|
2056
|
+
this.errorText_ = '';
|
|
2018
2057
|
this.sent_ = false;
|
|
2019
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2020
2058
|
this.fetch_ = nodeFetch;
|
|
2021
2059
|
this.errorCode_ = ErrorCode.NO_ERROR;
|
|
2022
2060
|
}
|
|
2023
|
-
send(url, method, body, headers) {
|
|
2061
|
+
async send(url, method, body, headers) {
|
|
2024
2062
|
if (this.sent_) {
|
|
2025
2063
|
throw internalError('cannot .send() more than once');
|
|
2026
2064
|
}
|
|
2027
2065
|
this.sent_ = true;
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
this.headers_ = resp.headers;
|
|
2034
|
-
this.statusCode_ = resp.status;
|
|
2035
|
-
return resp.text().then(body => {
|
|
2036
|
-
this.body_ = body;
|
|
2066
|
+
try {
|
|
2067
|
+
const response = await this.fetch_(url, {
|
|
2068
|
+
method,
|
|
2069
|
+
headers: headers || {},
|
|
2070
|
+
body: body
|
|
2037
2071
|
});
|
|
2038
|
-
|
|
2039
|
-
this.
|
|
2072
|
+
this.headers_ = response.headers;
|
|
2073
|
+
this.statusCode_ = response.status;
|
|
2074
|
+
this.errorCode_ = ErrorCode.NO_ERROR;
|
|
2075
|
+
this.body_ = await response.arrayBuffer();
|
|
2076
|
+
}
|
|
2077
|
+
catch (e) {
|
|
2078
|
+
this.errorText_ = e.message;
|
|
2040
2079
|
// emulate XHR which sets status to 0 when encountering a network error
|
|
2041
2080
|
this.statusCode_ = 0;
|
|
2042
|
-
|
|
2081
|
+
this.errorCode_ = ErrorCode.NETWORK_ERROR;
|
|
2082
|
+
}
|
|
2043
2083
|
}
|
|
2044
2084
|
getErrorCode() {
|
|
2045
2085
|
if (this.errorCode_ === undefined) {
|
|
@@ -2053,35 +2093,51 @@ class FetchConnection {
|
|
|
2053
2093
|
}
|
|
2054
2094
|
return this.statusCode_;
|
|
2055
2095
|
}
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
throw internalError('cannot .getResponseText() before receiving response');
|
|
2059
|
-
}
|
|
2060
|
-
return this.body_;
|
|
2096
|
+
getErrorText() {
|
|
2097
|
+
return this.errorText_;
|
|
2061
2098
|
}
|
|
2062
2099
|
abort() {
|
|
2063
2100
|
// Not supported
|
|
2064
2101
|
}
|
|
2065
2102
|
getResponseHeader(header) {
|
|
2066
2103
|
if (!this.headers_) {
|
|
2067
|
-
throw internalError('cannot .
|
|
2104
|
+
throw internalError('cannot .getResponseHeader() before receiving response');
|
|
2068
2105
|
}
|
|
2069
2106
|
return this.headers_.get(header);
|
|
2070
2107
|
}
|
|
2071
2108
|
addUploadProgressListener(listener) {
|
|
2072
2109
|
// Not supported
|
|
2073
2110
|
}
|
|
2074
|
-
/**
|
|
2075
|
-
* @override
|
|
2076
|
-
*/
|
|
2077
2111
|
removeUploadProgressListener(listener) {
|
|
2078
2112
|
// Not supported
|
|
2079
2113
|
}
|
|
2080
2114
|
}
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2115
|
+
class FetchTextConnection extends FetchConnection {
|
|
2116
|
+
getResponse() {
|
|
2117
|
+
if (!this.body_) {
|
|
2118
|
+
throw internalError('cannot .getResponse() before receiving response');
|
|
2119
|
+
}
|
|
2120
|
+
return Buffer.from(this.body_).toString('utf-8');
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
function newTextConnection() {
|
|
2124
|
+
return textFactoryOverride
|
|
2125
|
+
? textFactoryOverride()
|
|
2126
|
+
: new FetchTextConnection();
|
|
2127
|
+
}
|
|
2128
|
+
class FetchBytesConnection extends FetchConnection {
|
|
2129
|
+
getResponse() {
|
|
2130
|
+
if (!this.body_) {
|
|
2131
|
+
throw internalError('cannot .getResponse() before sending');
|
|
2132
|
+
}
|
|
2133
|
+
return this.body_;
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
function newBytesConnection() {
|
|
2137
|
+
return new FetchBytesConnection();
|
|
2138
|
+
}
|
|
2139
|
+
function newBlobConnection() {
|
|
2140
|
+
throw new Error('Blobs are not supported on Node');
|
|
2085
2141
|
}
|
|
2086
2142
|
|
|
2087
2143
|
/**
|
|
@@ -2223,7 +2279,7 @@ class UploadTask {
|
|
|
2223
2279
|
_createResumable() {
|
|
2224
2280
|
this._resolveToken((authToken, appCheckToken) => {
|
|
2225
2281
|
const requestInfo = createResumableUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata);
|
|
2226
|
-
const createRequest = this._ref.storage._makeRequest(requestInfo,
|
|
2282
|
+
const createRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
|
|
2227
2283
|
this._request = createRequest;
|
|
2228
2284
|
createRequest.getPromise().then((url) => {
|
|
2229
2285
|
this._request = undefined;
|
|
@@ -2238,7 +2294,7 @@ class UploadTask {
|
|
|
2238
2294
|
const url = this._uploadUrl;
|
|
2239
2295
|
this._resolveToken((authToken, appCheckToken) => {
|
|
2240
2296
|
const requestInfo = getResumableUploadStatus(this._ref.storage, this._ref._location, url, this._blob);
|
|
2241
|
-
const statusRequest = this._ref.storage._makeRequest(requestInfo,
|
|
2297
|
+
const statusRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
|
|
2242
2298
|
this._request = statusRequest;
|
|
2243
2299
|
statusRequest.getPromise().then(status => {
|
|
2244
2300
|
status = status;
|
|
@@ -2267,7 +2323,7 @@ class UploadTask {
|
|
|
2267
2323
|
this._transition("error" /* ERROR */);
|
|
2268
2324
|
return;
|
|
2269
2325
|
}
|
|
2270
|
-
const uploadRequest = this._ref.storage._makeRequest(requestInfo,
|
|
2326
|
+
const uploadRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
|
|
2271
2327
|
this._request = uploadRequest;
|
|
2272
2328
|
uploadRequest.getPromise().then((newStatus) => {
|
|
2273
2329
|
this._increaseMultiplier();
|
|
@@ -2293,7 +2349,7 @@ class UploadTask {
|
|
|
2293
2349
|
_fetchMetadata() {
|
|
2294
2350
|
this._resolveToken((authToken, appCheckToken) => {
|
|
2295
2351
|
const requestInfo = getMetadata$2(this._ref.storage, this._ref._location, this._mappings);
|
|
2296
|
-
const metadataRequest = this._ref.storage._makeRequest(requestInfo,
|
|
2352
|
+
const metadataRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
|
|
2297
2353
|
this._request = metadataRequest;
|
|
2298
2354
|
metadataRequest.getPromise().then(metadata => {
|
|
2299
2355
|
this._request = undefined;
|
|
@@ -2305,7 +2361,7 @@ class UploadTask {
|
|
|
2305
2361
|
_oneShotUpload() {
|
|
2306
2362
|
this._resolveToken((authToken, appCheckToken) => {
|
|
2307
2363
|
const requestInfo = multipartUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata);
|
|
2308
|
-
const multipartRequest = this._ref.storage._makeRequest(requestInfo,
|
|
2364
|
+
const multipartRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
|
|
2309
2365
|
this._request = multipartRequest;
|
|
2310
2366
|
multipartRequest.getPromise().then(metadata => {
|
|
2311
2367
|
this._request = undefined;
|
|
@@ -2670,6 +2726,34 @@ class Reference {
|
|
|
2670
2726
|
}
|
|
2671
2727
|
}
|
|
2672
2728
|
}
|
|
2729
|
+
/**
|
|
2730
|
+
* Download the bytes at the object's location.
|
|
2731
|
+
* @returns A Promise containing the downloaded bytes.
|
|
2732
|
+
*/
|
|
2733
|
+
function getBytesInternal(ref, maxDownloadSizeBytes) {
|
|
2734
|
+
ref._throwIfRoot('getBytes');
|
|
2735
|
+
const requestInfo = getBytes$1(ref.storage, ref._location, maxDownloadSizeBytes);
|
|
2736
|
+
return ref.storage
|
|
2737
|
+
.makeRequestWithTokens(requestInfo, newBytesConnection)
|
|
2738
|
+
.then(bytes => maxDownloadSizeBytes !== undefined
|
|
2739
|
+
? // GCS may not honor the Range header for small files
|
|
2740
|
+
bytes.slice(0, maxDownloadSizeBytes)
|
|
2741
|
+
: bytes);
|
|
2742
|
+
}
|
|
2743
|
+
/**
|
|
2744
|
+
* Download the bytes at the object's location.
|
|
2745
|
+
* @returns A Promise containing the downloaded blob.
|
|
2746
|
+
*/
|
|
2747
|
+
function getBlobInternal(ref, maxDownloadSizeBytes) {
|
|
2748
|
+
ref._throwIfRoot('getBlob');
|
|
2749
|
+
const requestInfo = getBytes$1(ref.storage, ref._location, maxDownloadSizeBytes);
|
|
2750
|
+
return ref.storage
|
|
2751
|
+
.makeRequestWithTokens(requestInfo, newBlobConnection)
|
|
2752
|
+
.then(blob => maxDownloadSizeBytes !== undefined
|
|
2753
|
+
? // GCS may not honor the Range header for small files
|
|
2754
|
+
blob.slice(0, maxDownloadSizeBytes)
|
|
2755
|
+
: blob);
|
|
2756
|
+
}
|
|
2673
2757
|
/**
|
|
2674
2758
|
* Uploads data to this object's location.
|
|
2675
2759
|
* The upload is not resumable.
|
|
@@ -2683,7 +2767,7 @@ function uploadBytes$1(ref, data, metadata) {
|
|
|
2683
2767
|
ref._throwIfRoot('uploadBytes');
|
|
2684
2768
|
const requestInfo = multipartUpload(ref.storage, ref._location, getMappings(), new FbsBlob(data, true), metadata);
|
|
2685
2769
|
return ref.storage
|
|
2686
|
-
.makeRequestWithTokens(requestInfo,
|
|
2770
|
+
.makeRequestWithTokens(requestInfo, newTextConnection)
|
|
2687
2771
|
.then(finalMetadata => {
|
|
2688
2772
|
return {
|
|
2689
2773
|
metadata: finalMetadata,
|
|
@@ -2800,7 +2884,7 @@ function list$1(ref, options) {
|
|
|
2800
2884
|
const op = options || {};
|
|
2801
2885
|
const requestInfo = list$2(ref.storage, ref._location,
|
|
2802
2886
|
/*delimiter= */ '/', op.pageToken, op.maxResults);
|
|
2803
|
-
return ref.storage.makeRequestWithTokens(requestInfo,
|
|
2887
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);
|
|
2804
2888
|
}
|
|
2805
2889
|
/**
|
|
2806
2890
|
* A `Promise` that resolves with the metadata for this object. If this
|
|
@@ -2812,7 +2896,7 @@ function list$1(ref, options) {
|
|
|
2812
2896
|
function getMetadata$1(ref) {
|
|
2813
2897
|
ref._throwIfRoot('getMetadata');
|
|
2814
2898
|
const requestInfo = getMetadata$2(ref.storage, ref._location, getMappings());
|
|
2815
|
-
return ref.storage.makeRequestWithTokens(requestInfo,
|
|
2899
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);
|
|
2816
2900
|
}
|
|
2817
2901
|
/**
|
|
2818
2902
|
* Updates the metadata for this object.
|
|
@@ -2828,7 +2912,7 @@ function getMetadata$1(ref) {
|
|
|
2828
2912
|
function updateMetadata$1(ref, metadata) {
|
|
2829
2913
|
ref._throwIfRoot('updateMetadata');
|
|
2830
2914
|
const requestInfo = updateMetadata$2(ref.storage, ref._location, metadata, getMappings());
|
|
2831
|
-
return ref.storage.makeRequestWithTokens(requestInfo,
|
|
2915
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);
|
|
2832
2916
|
}
|
|
2833
2917
|
/**
|
|
2834
2918
|
* Returns the download URL for the given Reference.
|
|
@@ -2840,7 +2924,7 @@ function getDownloadURL$1(ref) {
|
|
|
2840
2924
|
ref._throwIfRoot('getDownloadURL');
|
|
2841
2925
|
const requestInfo = getDownloadUrl(ref.storage, ref._location, getMappings());
|
|
2842
2926
|
return ref.storage
|
|
2843
|
-
.makeRequestWithTokens(requestInfo,
|
|
2927
|
+
.makeRequestWithTokens(requestInfo, newTextConnection)
|
|
2844
2928
|
.then(url => {
|
|
2845
2929
|
if (url === null) {
|
|
2846
2930
|
throw noDownloadURL();
|
|
@@ -2857,7 +2941,7 @@ function getDownloadURL$1(ref) {
|
|
|
2857
2941
|
function deleteObject$1(ref) {
|
|
2858
2942
|
ref._throwIfRoot('deleteObject');
|
|
2859
2943
|
const requestInfo = deleteObject$2(ref.storage, ref._location);
|
|
2860
|
-
return ref.storage.makeRequestWithTokens(requestInfo,
|
|
2944
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);
|
|
2861
2945
|
}
|
|
2862
2946
|
/**
|
|
2863
2947
|
* Returns reference for object obtained by appending `childPath` to `ref`.
|
|
@@ -3114,7 +3198,7 @@ class FirebaseStorageImpl {
|
|
|
3114
3198
|
}
|
|
3115
3199
|
|
|
3116
3200
|
const name = "@firebase/storage";
|
|
3117
|
-
const version = "0.8.
|
|
3201
|
+
const version = "0.8.7-canary.ce39a1a07";
|
|
3118
3202
|
|
|
3119
3203
|
/**
|
|
3120
3204
|
* @license
|
|
@@ -3153,6 +3237,24 @@ const STORAGE_TYPE = 'storage';
|
|
|
3153
3237
|
* See the License for the specific language governing permissions and
|
|
3154
3238
|
* limitations under the License.
|
|
3155
3239
|
*/
|
|
3240
|
+
/**
|
|
3241
|
+
* Downloads the data at the object's location. Returns an error if the object
|
|
3242
|
+
* is not found.
|
|
3243
|
+
*
|
|
3244
|
+
* To use this functionality, you have to whitelist your app's origin in your
|
|
3245
|
+
* Cloud Storage bucket. See also
|
|
3246
|
+
* https://cloud.google.com/storage/docs/configuring-cors
|
|
3247
|
+
*
|
|
3248
|
+
* @public
|
|
3249
|
+
* @param ref - StorageReference where data should be downloaded.
|
|
3250
|
+
* @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
|
|
3251
|
+
* retrieve.
|
|
3252
|
+
* @returns A Promise containing the object's bytes
|
|
3253
|
+
*/
|
|
3254
|
+
function getBytes(ref, maxDownloadSizeBytes) {
|
|
3255
|
+
ref = getModularInstance(ref);
|
|
3256
|
+
return getBytesInternal(ref, maxDownloadSizeBytes);
|
|
3257
|
+
}
|
|
3156
3258
|
/**
|
|
3157
3259
|
* Uploads data to this object's location.
|
|
3158
3260
|
* The upload is not resumable.
|
|
@@ -3327,6 +3429,58 @@ function connectStorageEmulator(storage, host, port, options = {}) {
|
|
|
3327
3429
|
connectStorageEmulator$1(storage, host, port, options);
|
|
3328
3430
|
}
|
|
3329
3431
|
|
|
3432
|
+
/**
|
|
3433
|
+
* @license
|
|
3434
|
+
* Copyright 2021 Google LLC
|
|
3435
|
+
*
|
|
3436
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3437
|
+
* you may not use this file except in compliance with the License.
|
|
3438
|
+
* You may obtain a copy of the License at
|
|
3439
|
+
*
|
|
3440
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3441
|
+
*
|
|
3442
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3443
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3444
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3445
|
+
* See the License for the specific language governing permissions and
|
|
3446
|
+
* limitations under the License.
|
|
3447
|
+
*/
|
|
3448
|
+
/**
|
|
3449
|
+
* Downloads the data at the object's location. Returns an error if the object
|
|
3450
|
+
* is not found.
|
|
3451
|
+
*
|
|
3452
|
+
* To use this functionality, you have to whitelist your app's origin in your
|
|
3453
|
+
* Cloud Storage bucket. See also
|
|
3454
|
+
* https://cloud.google.com/storage/docs/configuring-cors
|
|
3455
|
+
*
|
|
3456
|
+
* This API is not available in Node.
|
|
3457
|
+
*
|
|
3458
|
+
* @public
|
|
3459
|
+
* @param ref - StorageReference where data should be downloaded.
|
|
3460
|
+
* @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
|
|
3461
|
+
* retrieve.
|
|
3462
|
+
* @returns A Promise that resolves with a Blob containing the object's bytes
|
|
3463
|
+
*/
|
|
3464
|
+
function getBlob(ref, maxDownloadSizeBytes) {
|
|
3465
|
+
ref = getModularInstance(ref);
|
|
3466
|
+
return getBlobInternal(ref, maxDownloadSizeBytes);
|
|
3467
|
+
}
|
|
3468
|
+
/**
|
|
3469
|
+
* Downloads the data at the object's location. Raises an error event if the
|
|
3470
|
+
* object is not found.
|
|
3471
|
+
*
|
|
3472
|
+
* This API is only available in Node.
|
|
3473
|
+
*
|
|
3474
|
+
* @public
|
|
3475
|
+
* @param ref - StorageReference where data should be downloaded.
|
|
3476
|
+
* @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
|
|
3477
|
+
* retrieve.
|
|
3478
|
+
* @returns A stream with the object's data as bytes
|
|
3479
|
+
*/
|
|
3480
|
+
function getStream(ref, maxDownloadSizeBytes) {
|
|
3481
|
+
throw new Error('getStream() is only supported by NodeJS builds');
|
|
3482
|
+
}
|
|
3483
|
+
|
|
3330
3484
|
/**
|
|
3331
3485
|
* Cloud Storage for Firebase
|
|
3332
3486
|
*
|
|
@@ -3347,5 +3501,5 @@ function registerStorage() {
|
|
|
3347
3501
|
}
|
|
3348
3502
|
registerStorage();
|
|
3349
3503
|
|
|
3350
|
-
export { StringFormat, FbsBlob as _FbsBlob, Location as _Location, TaskEvent as _TaskEvent, TaskState as _TaskState, UploadTask as _UploadTask, dataFromString as _dataFromString, _getChild, invalidArgument as _invalidArgument, invalidRootOperation as _invalidRootOperation, connectStorageEmulator, deleteObject, getDownloadURL, getMetadata, getStorage, list, listAll, ref, updateMetadata, uploadBytes, uploadBytesResumable, uploadString };
|
|
3504
|
+
export { StringFormat, FbsBlob as _FbsBlob, Location as _Location, TaskEvent as _TaskEvent, TaskState as _TaskState, UploadTask as _UploadTask, dataFromString as _dataFromString, _getChild, invalidArgument as _invalidArgument, invalidRootOperation as _invalidRootOperation, connectStorageEmulator, deleteObject, getBlob, getBytes, getDownloadURL, getMetadata, getStorage, getStream, list, listAll, ref, updateMetadata, uploadBytes, uploadBytesResumable, uploadString };
|
|
3351
3505
|
//# sourceMappingURL=index.node.esm.js.map
|