@firebase/storage 0.8.7 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/index.browser.cjs.js +198 -25
- package/dist/index.browser.cjs.js.map +1 -1
- package/dist/index.esm2017.js +177 -26
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +196 -26
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +245 -45
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/node-esm/index.node.esm.js +189 -46
- 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 +2 -2
|
@@ -557,6 +557,14 @@ var ErrorCode;
|
|
|
557
557
|
* See the License for the specific language governing permissions and
|
|
558
558
|
* limitations under the License.
|
|
559
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
|
+
*/
|
|
560
568
|
class NetworkRequest {
|
|
561
569
|
constructor(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, connectionFactory_) {
|
|
562
570
|
this.url_ = url_;
|
|
@@ -633,7 +641,7 @@ class NetworkRequest {
|
|
|
633
641
|
const connection = status.connection;
|
|
634
642
|
if (status.wasSuccessCode) {
|
|
635
643
|
try {
|
|
636
|
-
const result = this.callback_(connection, connection.
|
|
644
|
+
const result = this.callback_(connection, connection.getResponse());
|
|
637
645
|
if (isJustDef(result)) {
|
|
638
646
|
resolve(result);
|
|
639
647
|
}
|
|
@@ -648,7 +656,7 @@ class NetworkRequest {
|
|
|
648
656
|
else {
|
|
649
657
|
if (connection !== null) {
|
|
650
658
|
const err = unknown();
|
|
651
|
-
err.serverResponse = connection.
|
|
659
|
+
err.serverResponse = connection.getErrorText();
|
|
652
660
|
if (this.errorCallback_) {
|
|
653
661
|
reject(this.errorCallback_(connection, err));
|
|
654
662
|
}
|
|
@@ -779,7 +787,7 @@ function getBlobBuilder() {
|
|
|
779
787
|
* @param args The values that will make up the resulting blob.
|
|
780
788
|
* @return The blob.
|
|
781
789
|
*/
|
|
782
|
-
function getBlob(...args) {
|
|
790
|
+
function getBlob$1(...args) {
|
|
783
791
|
const BlobBuilder = getBlobBuilder();
|
|
784
792
|
if (BlobBuilder !== undefined) {
|
|
785
793
|
const bb = new BlobBuilder();
|
|
@@ -1134,7 +1142,7 @@ class FbsBlob {
|
|
|
1134
1142
|
return val;
|
|
1135
1143
|
}
|
|
1136
1144
|
});
|
|
1137
|
-
return new FbsBlob(getBlob.apply(null, blobby));
|
|
1145
|
+
return new FbsBlob(getBlob$1.apply(null, blobby));
|
|
1138
1146
|
}
|
|
1139
1147
|
else {
|
|
1140
1148
|
const uint8Arrays = args.map((val) => {
|
|
@@ -1456,6 +1464,12 @@ function fromResponseString(service, bucket, resourceString) {
|
|
|
1456
1464
|
return fromBackendResponse(service, bucket, resource);
|
|
1457
1465
|
}
|
|
1458
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
|
+
*/
|
|
1459
1473
|
class RequestInfo {
|
|
1460
1474
|
constructor(url, method,
|
|
1461
1475
|
/**
|
|
@@ -1539,7 +1553,7 @@ function sharedErrorHandler(location) {
|
|
|
1539
1553
|
if (
|
|
1540
1554
|
// This exact message string is the only consistent part of the
|
|
1541
1555
|
// server's error response that identifies it as an App Check error.
|
|
1542
|
-
xhr.
|
|
1556
|
+
xhr.getErrorText().includes('Firebase App Check token is invalid')) {
|
|
1543
1557
|
newErr = unauthorizedApp();
|
|
1544
1558
|
}
|
|
1545
1559
|
else {
|
|
@@ -1611,6 +1625,19 @@ function list$2(service, location, delimiter, pageToken, maxResults) {
|
|
|
1611
1625
|
requestInfo.errorHandler = sharedErrorHandler(location);
|
|
1612
1626
|
return requestInfo;
|
|
1613
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
|
+
}
|
|
1614
1641
|
function getDownloadUrl(service, location, mappings) {
|
|
1615
1642
|
const urlPart = location.fullServerUrl();
|
|
1616
1643
|
const url = makeUrl(urlPart, service.host, service._protocol);
|
|
@@ -2017,7 +2044,7 @@ function async(f) {
|
|
|
2017
2044
|
* limitations under the License.
|
|
2018
2045
|
*/
|
|
2019
2046
|
/** An override for the text-based Connection. Used in tests. */
|
|
2020
|
-
let
|
|
2047
|
+
let textFactoryOverride = null;
|
|
2021
2048
|
/**
|
|
2022
2049
|
* Network layer that works in Node.
|
|
2023
2050
|
*
|
|
@@ -2026,31 +2053,33 @@ let connectionFactoryOverride = null;
|
|
|
2026
2053
|
*/
|
|
2027
2054
|
class FetchConnection {
|
|
2028
2055
|
constructor() {
|
|
2056
|
+
this.errorText_ = '';
|
|
2029
2057
|
this.sent_ = false;
|
|
2030
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2031
2058
|
this.fetch_ = nodeFetch;
|
|
2032
2059
|
this.errorCode_ = ErrorCode.NO_ERROR;
|
|
2033
2060
|
}
|
|
2034
|
-
send(url, method, body, headers) {
|
|
2061
|
+
async send(url, method, body, headers) {
|
|
2035
2062
|
if (this.sent_) {
|
|
2036
2063
|
throw internalError('cannot .send() more than once');
|
|
2037
2064
|
}
|
|
2038
2065
|
this.sent_ = true;
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
this.headers_ = resp.headers;
|
|
2045
|
-
this.statusCode_ = resp.status;
|
|
2046
|
-
return resp.text().then(body => {
|
|
2047
|
-
this.body_ = body;
|
|
2066
|
+
try {
|
|
2067
|
+
const response = await this.fetch_(url, {
|
|
2068
|
+
method,
|
|
2069
|
+
headers: headers || {},
|
|
2070
|
+
body: body
|
|
2048
2071
|
});
|
|
2049
|
-
|
|
2050
|
-
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;
|
|
2051
2079
|
// emulate XHR which sets status to 0 when encountering a network error
|
|
2052
2080
|
this.statusCode_ = 0;
|
|
2053
|
-
|
|
2081
|
+
this.errorCode_ = ErrorCode.NETWORK_ERROR;
|
|
2082
|
+
}
|
|
2054
2083
|
}
|
|
2055
2084
|
getErrorCode() {
|
|
2056
2085
|
if (this.errorCode_ === undefined) {
|
|
@@ -2064,35 +2093,51 @@ class FetchConnection {
|
|
|
2064
2093
|
}
|
|
2065
2094
|
return this.statusCode_;
|
|
2066
2095
|
}
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
throw internalError('cannot .getResponseText() before receiving response');
|
|
2070
|
-
}
|
|
2071
|
-
return this.body_;
|
|
2096
|
+
getErrorText() {
|
|
2097
|
+
return this.errorText_;
|
|
2072
2098
|
}
|
|
2073
2099
|
abort() {
|
|
2074
2100
|
// Not supported
|
|
2075
2101
|
}
|
|
2076
2102
|
getResponseHeader(header) {
|
|
2077
2103
|
if (!this.headers_) {
|
|
2078
|
-
throw internalError('cannot .
|
|
2104
|
+
throw internalError('cannot .getResponseHeader() before receiving response');
|
|
2079
2105
|
}
|
|
2080
2106
|
return this.headers_.get(header);
|
|
2081
2107
|
}
|
|
2082
2108
|
addUploadProgressListener(listener) {
|
|
2083
2109
|
// Not supported
|
|
2084
2110
|
}
|
|
2085
|
-
/**
|
|
2086
|
-
* @override
|
|
2087
|
-
*/
|
|
2088
2111
|
removeUploadProgressListener(listener) {
|
|
2089
2112
|
// Not supported
|
|
2090
2113
|
}
|
|
2091
2114
|
}
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
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');
|
|
2096
2141
|
}
|
|
2097
2142
|
|
|
2098
2143
|
/**
|
|
@@ -2234,7 +2279,7 @@ class UploadTask {
|
|
|
2234
2279
|
_createResumable() {
|
|
2235
2280
|
this._resolveToken((authToken, appCheckToken) => {
|
|
2236
2281
|
const requestInfo = createResumableUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata);
|
|
2237
|
-
const createRequest = this._ref.storage._makeRequest(requestInfo,
|
|
2282
|
+
const createRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
|
|
2238
2283
|
this._request = createRequest;
|
|
2239
2284
|
createRequest.getPromise().then((url) => {
|
|
2240
2285
|
this._request = undefined;
|
|
@@ -2249,7 +2294,7 @@ class UploadTask {
|
|
|
2249
2294
|
const url = this._uploadUrl;
|
|
2250
2295
|
this._resolveToken((authToken, appCheckToken) => {
|
|
2251
2296
|
const requestInfo = getResumableUploadStatus(this._ref.storage, this._ref._location, url, this._blob);
|
|
2252
|
-
const statusRequest = this._ref.storage._makeRequest(requestInfo,
|
|
2297
|
+
const statusRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
|
|
2253
2298
|
this._request = statusRequest;
|
|
2254
2299
|
statusRequest.getPromise().then(status => {
|
|
2255
2300
|
status = status;
|
|
@@ -2278,7 +2323,7 @@ class UploadTask {
|
|
|
2278
2323
|
this._transition("error" /* ERROR */);
|
|
2279
2324
|
return;
|
|
2280
2325
|
}
|
|
2281
|
-
const uploadRequest = this._ref.storage._makeRequest(requestInfo,
|
|
2326
|
+
const uploadRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
|
|
2282
2327
|
this._request = uploadRequest;
|
|
2283
2328
|
uploadRequest.getPromise().then((newStatus) => {
|
|
2284
2329
|
this._increaseMultiplier();
|
|
@@ -2304,7 +2349,7 @@ class UploadTask {
|
|
|
2304
2349
|
_fetchMetadata() {
|
|
2305
2350
|
this._resolveToken((authToken, appCheckToken) => {
|
|
2306
2351
|
const requestInfo = getMetadata$2(this._ref.storage, this._ref._location, this._mappings);
|
|
2307
|
-
const metadataRequest = this._ref.storage._makeRequest(requestInfo,
|
|
2352
|
+
const metadataRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
|
|
2308
2353
|
this._request = metadataRequest;
|
|
2309
2354
|
metadataRequest.getPromise().then(metadata => {
|
|
2310
2355
|
this._request = undefined;
|
|
@@ -2316,7 +2361,7 @@ class UploadTask {
|
|
|
2316
2361
|
_oneShotUpload() {
|
|
2317
2362
|
this._resolveToken((authToken, appCheckToken) => {
|
|
2318
2363
|
const requestInfo = multipartUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata);
|
|
2319
|
-
const multipartRequest = this._ref.storage._makeRequest(requestInfo,
|
|
2364
|
+
const multipartRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
|
|
2320
2365
|
this._request = multipartRequest;
|
|
2321
2366
|
multipartRequest.getPromise().then(metadata => {
|
|
2322
2367
|
this._request = undefined;
|
|
@@ -2681,6 +2726,34 @@ class Reference {
|
|
|
2681
2726
|
}
|
|
2682
2727
|
}
|
|
2683
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
|
+
}
|
|
2684
2757
|
/**
|
|
2685
2758
|
* Uploads data to this object's location.
|
|
2686
2759
|
* The upload is not resumable.
|
|
@@ -2694,7 +2767,7 @@ function uploadBytes$1(ref, data, metadata) {
|
|
|
2694
2767
|
ref._throwIfRoot('uploadBytes');
|
|
2695
2768
|
const requestInfo = multipartUpload(ref.storage, ref._location, getMappings(), new FbsBlob(data, true), metadata);
|
|
2696
2769
|
return ref.storage
|
|
2697
|
-
.makeRequestWithTokens(requestInfo,
|
|
2770
|
+
.makeRequestWithTokens(requestInfo, newTextConnection)
|
|
2698
2771
|
.then(finalMetadata => {
|
|
2699
2772
|
return {
|
|
2700
2773
|
metadata: finalMetadata,
|
|
@@ -2811,7 +2884,7 @@ function list$1(ref, options) {
|
|
|
2811
2884
|
const op = options || {};
|
|
2812
2885
|
const requestInfo = list$2(ref.storage, ref._location,
|
|
2813
2886
|
/*delimiter= */ '/', op.pageToken, op.maxResults);
|
|
2814
|
-
return ref.storage.makeRequestWithTokens(requestInfo,
|
|
2887
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);
|
|
2815
2888
|
}
|
|
2816
2889
|
/**
|
|
2817
2890
|
* A `Promise` that resolves with the metadata for this object. If this
|
|
@@ -2823,7 +2896,7 @@ function list$1(ref, options) {
|
|
|
2823
2896
|
function getMetadata$1(ref) {
|
|
2824
2897
|
ref._throwIfRoot('getMetadata');
|
|
2825
2898
|
const requestInfo = getMetadata$2(ref.storage, ref._location, getMappings());
|
|
2826
|
-
return ref.storage.makeRequestWithTokens(requestInfo,
|
|
2899
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);
|
|
2827
2900
|
}
|
|
2828
2901
|
/**
|
|
2829
2902
|
* Updates the metadata for this object.
|
|
@@ -2839,7 +2912,7 @@ function getMetadata$1(ref) {
|
|
|
2839
2912
|
function updateMetadata$1(ref, metadata) {
|
|
2840
2913
|
ref._throwIfRoot('updateMetadata');
|
|
2841
2914
|
const requestInfo = updateMetadata$2(ref.storage, ref._location, metadata, getMappings());
|
|
2842
|
-
return ref.storage.makeRequestWithTokens(requestInfo,
|
|
2915
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);
|
|
2843
2916
|
}
|
|
2844
2917
|
/**
|
|
2845
2918
|
* Returns the download URL for the given Reference.
|
|
@@ -2851,7 +2924,7 @@ function getDownloadURL$1(ref) {
|
|
|
2851
2924
|
ref._throwIfRoot('getDownloadURL');
|
|
2852
2925
|
const requestInfo = getDownloadUrl(ref.storage, ref._location, getMappings());
|
|
2853
2926
|
return ref.storage
|
|
2854
|
-
.makeRequestWithTokens(requestInfo,
|
|
2927
|
+
.makeRequestWithTokens(requestInfo, newTextConnection)
|
|
2855
2928
|
.then(url => {
|
|
2856
2929
|
if (url === null) {
|
|
2857
2930
|
throw noDownloadURL();
|
|
@@ -2868,7 +2941,7 @@ function getDownloadURL$1(ref) {
|
|
|
2868
2941
|
function deleteObject$1(ref) {
|
|
2869
2942
|
ref._throwIfRoot('deleteObject');
|
|
2870
2943
|
const requestInfo = deleteObject$2(ref.storage, ref._location);
|
|
2871
|
-
return ref.storage.makeRequestWithTokens(requestInfo,
|
|
2944
|
+
return ref.storage.makeRequestWithTokens(requestInfo, newTextConnection);
|
|
2872
2945
|
}
|
|
2873
2946
|
/**
|
|
2874
2947
|
* Returns reference for object obtained by appending `childPath` to `ref`.
|
|
@@ -3125,7 +3198,7 @@ class FirebaseStorageImpl {
|
|
|
3125
3198
|
}
|
|
3126
3199
|
|
|
3127
3200
|
const name = "@firebase/storage";
|
|
3128
|
-
const version = "0.
|
|
3201
|
+
const version = "0.9.0";
|
|
3129
3202
|
|
|
3130
3203
|
/**
|
|
3131
3204
|
* @license
|
|
@@ -3164,6 +3237,24 @@ const STORAGE_TYPE = 'storage';
|
|
|
3164
3237
|
* See the License for the specific language governing permissions and
|
|
3165
3238
|
* limitations under the License.
|
|
3166
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
|
+
}
|
|
3167
3258
|
/**
|
|
3168
3259
|
* Uploads data to this object's location.
|
|
3169
3260
|
* The upload is not resumable.
|
|
@@ -3338,6 +3429,58 @@ function connectStorageEmulator(storage, host, port, options = {}) {
|
|
|
3338
3429
|
connectStorageEmulator$1(storage, host, port, options);
|
|
3339
3430
|
}
|
|
3340
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
|
+
|
|
3341
3484
|
/**
|
|
3342
3485
|
* Cloud Storage for Firebase
|
|
3343
3486
|
*
|
|
@@ -3358,5 +3501,5 @@ function registerStorage() {
|
|
|
3358
3501
|
}
|
|
3359
3502
|
registerStorage();
|
|
3360
3503
|
|
|
3361
|
-
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 };
|
|
3362
3505
|
//# sourceMappingURL=index.node.esm.js.map
|