@supabase/storage-js 2.95.2 → 2.95.4-canary.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/dist/index.cjs +35 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +110 -71
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +110 -71
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +35 -3
- package/dist/index.mjs.map +1 -1
- package/dist/umd/supabase.js +1 -1
- package/package.json +1 -1
- package/src/lib/common/BaseApiClient.ts +13 -0
- package/src/lib/common/fetch.ts +1 -7
- package/src/lib/types.ts +11 -0
- package/src/lib/version.ts +1 -1
- package/src/packages/StorageFileApi.ts +31 -5
package/dist/index.cjs
CHANGED
|
@@ -390,6 +390,18 @@ var BaseApiClient = class {
|
|
|
390
390
|
return this;
|
|
391
391
|
}
|
|
392
392
|
/**
|
|
393
|
+
* Set an HTTP header for the request.
|
|
394
|
+
* Creates a shallow copy of headers to avoid mutating shared state.
|
|
395
|
+
*
|
|
396
|
+
* @param name - Header name
|
|
397
|
+
* @param value - Header value
|
|
398
|
+
* @returns this - For method chaining
|
|
399
|
+
*/
|
|
400
|
+
setHeader(name, value) {
|
|
401
|
+
this.headers = _objectSpread2(_objectSpread2({}, this.headers), {}, { [name]: value });
|
|
402
|
+
return this;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
393
405
|
* Handles API operation with standardized error handling
|
|
394
406
|
* Eliminates repetitive try-catch blocks across all API methods
|
|
395
407
|
*
|
|
@@ -957,6 +969,7 @@ var StorageFileApi = class extends BaseApiClient {
|
|
|
957
969
|
* @category File Buckets
|
|
958
970
|
* @param path The full path and file name of the file to be downloaded. For example `folder/image.png`.
|
|
959
971
|
* @param options.transform Transform the asset before serving it to the client.
|
|
972
|
+
* @param parameters Additional fetch parameters like signal for cancellation. Supports standard fetch options including cache control.
|
|
960
973
|
* @returns BlobDownloadBuilder instance for downloading the file
|
|
961
974
|
*
|
|
962
975
|
* @example Download file
|
|
@@ -988,8 +1001,27 @@ var StorageFileApi = class extends BaseApiClient {
|
|
|
988
1001
|
* }
|
|
989
1002
|
* })
|
|
990
1003
|
* ```
|
|
1004
|
+
*
|
|
1005
|
+
* @example Download with cache control (useful in Edge Functions)
|
|
1006
|
+
* ```js
|
|
1007
|
+
* const { data, error } = await supabase
|
|
1008
|
+
* .storage
|
|
1009
|
+
* .from('avatars')
|
|
1010
|
+
* .download('folder/avatar1.png', {}, { cache: 'no-store' })
|
|
1011
|
+
* ```
|
|
1012
|
+
*
|
|
1013
|
+
* @example Download with abort signal
|
|
1014
|
+
* ```js
|
|
1015
|
+
* const controller = new AbortController()
|
|
1016
|
+
* setTimeout(() => controller.abort(), 5000)
|
|
1017
|
+
*
|
|
1018
|
+
* const { data, error } = await supabase
|
|
1019
|
+
* .storage
|
|
1020
|
+
* .from('avatars')
|
|
1021
|
+
* .download('folder/avatar1.png', {}, { signal: controller.signal })
|
|
1022
|
+
* ```
|
|
991
1023
|
*/
|
|
992
|
-
download(path, options) {
|
|
1024
|
+
download(path, options, parameters) {
|
|
993
1025
|
const renderPath = typeof (options === null || options === void 0 ? void 0 : options.transform) !== "undefined" ? "render/image/authenticated" : "object";
|
|
994
1026
|
const transformationQuery = this.transformOptsToQueryString((options === null || options === void 0 ? void 0 : options.transform) || {});
|
|
995
1027
|
const queryString = transformationQuery ? `?${transformationQuery}` : "";
|
|
@@ -997,7 +1029,7 @@ var StorageFileApi = class extends BaseApiClient {
|
|
|
997
1029
|
const downloadFn = () => get(this.fetch, `${this.url}/${renderPath}/${_path}${queryString}`, {
|
|
998
1030
|
headers: this.headers,
|
|
999
1031
|
noResolveJson: true
|
|
1000
|
-
});
|
|
1032
|
+
}, parameters);
|
|
1001
1033
|
return new BlobDownloadBuilder(downloadFn, this.shouldThrowOnError);
|
|
1002
1034
|
}
|
|
1003
1035
|
/**
|
|
@@ -1264,7 +1296,7 @@ var StorageFileApi = class extends BaseApiClient {
|
|
|
1264
1296
|
|
|
1265
1297
|
//#endregion
|
|
1266
1298
|
//#region src/lib/version.ts
|
|
1267
|
-
const version = "2.95.
|
|
1299
|
+
const version = "2.95.4-canary.0";
|
|
1268
1300
|
|
|
1269
1301
|
//#endregion
|
|
1270
1302
|
//#region src/lib/constants.ts
|