@supabase/storage-js 2.118.0-canary.2 → 2.118.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/README.md CHANGED
@@ -1292,6 +1292,8 @@ pnpm nx test:clean-post storage-js
1292
1292
 
1293
1293
  The test infrastructure is managed via the Supabase CLI (`pnpm exec supabase start --workdir test`), which starts a local Supabase stack defined by the config in `test/`. This includes PostgreSQL, the Storage API, Kong Gateway, and supporting services.
1294
1294
 
1295
+ `test:infra` pins the Storage API image to the version in `test/supabase/storage-version`, since the encoding integration tests require Storage v1.80.0+. Update this file when upgrading the test server. CI includes this file in its Docker image cache key.
1296
+
1295
1297
  #### Common Issues and Solutions
1296
1298
 
1297
1299
  | Issue | Solution |
package/dist/index.cjs CHANGED
@@ -624,6 +624,7 @@ var StorageFileApi = class extends BaseApiClient {
624
624
  body = fileBody;
625
625
  headers["cache-control"] = `max-age=${options.cacheControl}`;
626
626
  headers["content-type"] = options.contentType;
627
+ if (options.contentEncoding) headers["content-encoding"] = options.contentEncoding;
627
628
  if (metadata) headers["x-metadata"] = _this.toBase64(_this.encodeMetadata(metadata));
628
629
  if ((typeof ReadableStream !== "undefined" && body instanceof ReadableStream || body && typeof body === "object" && "pipe" in body && typeof body.pipe === "function") && !options.duplex) options.duplex = "half";
629
630
  }
@@ -645,7 +646,7 @@ var StorageFileApi = class extends BaseApiClient {
645
646
  * @subcategory File Buckets
646
647
  * @param path The file path, including the file name. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.
647
648
  * @param fileBody The body of the file to be stored in the bucket.
648
- * @param fileOptions Optional file upload options including cacheControl, contentType, upsert, and metadata.
649
+ * @param fileOptions Optional file upload options including cacheControl, contentType, contentEncoding, upsert, and metadata.
649
650
  * @returns Promise with response containing file path, id, and fullPath or error
650
651
  *
651
652
  * @example Upload file
@@ -716,7 +717,7 @@ var StorageFileApi = class extends BaseApiClient {
716
717
  * @param path The file path, including the file name. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.
717
718
  * @param token The token generated from `createSignedUploadUrl`
718
719
  * @param fileBody The body of the file to be stored in the bucket.
719
- * @param fileOptions HTTP headers (cacheControl, contentType, etc.).
720
+ * @param fileOptions HTTP headers (cacheControl, contentType, contentEncoding, etc.).
720
721
  * **Note:** The `upsert` option has no effect here. To enable upsert behavior,
721
722
  * pass `{ upsert: true }` when calling `createSignedUploadUrl()` instead.
722
723
  * @returns Promise with response containing file path and fullPath or error
@@ -762,6 +763,7 @@ var StorageFileApi = class extends BaseApiClient {
762
763
  body = fileBody;
763
764
  headers["cache-control"] = `max-age=${options.cacheControl}`;
764
765
  headers["content-type"] = options.contentType;
766
+ if (options.contentEncoding) headers["content-encoding"] = options.contentEncoding;
765
767
  if (metadata) headers["x-metadata"] = _this3.toBase64(_this3.encodeMetadata(metadata));
766
768
  if ((typeof ReadableStream !== "undefined" && body instanceof ReadableStream || body && typeof body === "object" && "pipe" in body && typeof body.pipe === "function") && !options.duplex) options.duplex = "half";
767
769
  }
@@ -833,7 +835,7 @@ var StorageFileApi = class extends BaseApiClient {
833
835
  * @subcategory File Buckets
834
836
  * @param path The relative file path. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to update.
835
837
  * @param fileBody The body of the file to be stored in the bucket.
836
- * @param fileOptions Optional file upload options including cacheControl, contentType, and metadata.
838
+ * @param fileOptions Optional file upload options including cacheControl, contentType, contentEncoding, and metadata.
837
839
  * **Note:** The `upsert` option has no effect here. `update()` always replaces the
838
840
  * file at the given path, so the `x-upsert` header is not sent. To control upsert
839
841
  * behavior, use `upload()` instead.
@@ -938,8 +940,10 @@ var StorageFileApi = class extends BaseApiClient {
938
940
  * @subcategory File Buckets
939
941
  * @param fromPath The original file path, including the current file name. For example `folder/image.png`.
940
942
  * @param toPath The new file path, including the new file name. For example `folder/image-copy.png`.
941
- * @param options The destination options.
943
+ * @param options The destination and metadata options.
942
944
  * @param options.sourceVersionId The version id of the source object to copy.
945
+ * @param options.copyMetadata Whether to copy the source metadata. Defaults to true. Set to false to apply metadata overrides; custom user metadata is not copied when false.
946
+ * @param options.metadata File metadata overrides, applied only when copyMetadata is false. Unspecified fields retain their source values.
943
947
  * @returns Promise with response containing copied file path or error
944
948
  *
945
949
  * @example Copy file
@@ -960,6 +964,18 @@ var StorageFileApi = class extends BaseApiClient {
960
964
  * }
961
965
  * ```
962
966
  *
967
+ * @example Copy file with content encoding
968
+ * ```js
969
+ * const { data, error } = await supabase
970
+ * .storage
971
+ * .from('documents')
972
+ * .copy('source.txt.gz', 'copy.txt.gz', {
973
+ * copyMetadata: false,
974
+ * metadata: { contentEncoding: 'gzip' },
975
+ * })
976
+ * ```
977
+ * The source must already contain gzip-encoded bytes. Copying changes metadata only.
978
+ *
963
979
  * @remarks
964
980
  * - RLS policy permissions required:
965
981
  * - `buckets` table permissions: none
@@ -969,12 +985,15 @@ var StorageFileApi = class extends BaseApiClient {
969
985
  async copy(fromPath, toPath, options) {
970
986
  var _this7 = this;
971
987
  return _this7.handleOperation(async () => {
988
+ const copyOptions = options;
972
989
  return { path: (await post(_this7.fetch, `${_this7.url}/object/copy`, {
973
990
  bucketId: _this7.bucketId,
974
991
  sourceKey: fromPath,
975
992
  destinationKey: toPath,
976
993
  destinationBucket: options === null || options === void 0 ? void 0 : options.destinationBucket,
977
- sourceVersionId: options === null || options === void 0 ? void 0 : options.sourceVersionId
994
+ sourceVersionId: options === null || options === void 0 ? void 0 : options.sourceVersionId,
995
+ copyMetadata: typeof (copyOptions === null || copyOptions === void 0 ? void 0 : copyOptions.copyMetadata) === "boolean" ? copyOptions.copyMetadata : void 0,
996
+ metadata: (copyOptions === null || copyOptions === void 0 ? void 0 : copyOptions.copyMetadata) === false ? copyOptions.metadata : void 0
978
997
  }, { headers: _this7.headers })).Key };
979
998
  });
980
999
  }
@@ -1600,6 +1619,7 @@ var StorageFileApi = class extends BaseApiClient {
1600
1619
  else files.push(["", fileBody]);
1601
1620
  if (!body.has("cacheControl")) body.append("cacheControl", options.cacheControl);
1602
1621
  if (options.metadata && !body.has("metadata")) body.append("metadata", this.encodeMetadata(options.metadata));
1622
+ if (options.contentEncoding && !body.has("contentEncoding")) body.append("contentEncoding", options.contentEncoding);
1603
1623
  for (const [name, file] of files) body.append(name, file);
1604
1624
  return body;
1605
1625
  }
@@ -1629,7 +1649,7 @@ var StorageFileApi = class extends BaseApiClient {
1629
1649
 
1630
1650
  //#endregion
1631
1651
  //#region src/lib/version.ts
1632
- const version = "2.118.0-canary.2";
1652
+ const version = "2.118.0";
1633
1653
 
1634
1654
  //#endregion
1635
1655
  //#region src/lib/constants.ts