@supabase/storage-js 3.0.0-next.1 → 3.0.0-next.11

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
@@ -67,7 +67,7 @@ If you're already using `@supabase/supabase-js`, access storage through the clie
67
67
  ```js
68
68
  import { createClient } from '@supabase/supabase-js'
69
69
 
70
- // Use publishable/anon key for frontend applications
70
+ // Use publishable key for frontend applications
71
71
  const supabase = createClient('https://<project_ref>.supabase.co', '<your-publishable-key>')
72
72
 
73
73
  // Access storage
package/dist/index.cjs CHANGED
@@ -710,22 +710,28 @@ var StorageFileApi = class extends BaseApiClient {
710
710
  return _this3.handleOperation(async () => {
711
711
  let body;
712
712
  const options = _objectSpread2(_objectSpread2({}, DEFAULT_FILE_OPTIONS), fileOptions);
713
- const headers = _objectSpread2(_objectSpread2({}, _this3.headers), { "x-upsert": String(options.upsert) });
713
+ let headers = _objectSpread2(_objectSpread2({}, _this3.headers), { "x-upsert": String(options.upsert) });
714
+ const metadata = options.metadata;
714
715
  if (typeof Blob !== "undefined" && fileBody instanceof Blob) {
715
716
  body = new FormData();
716
717
  body.append("cacheControl", options.cacheControl);
718
+ if (metadata) body.append("metadata", _this3.encodeMetadata(metadata));
717
719
  body.append("", fileBody);
718
720
  } else if (typeof FormData !== "undefined" && fileBody instanceof FormData) {
719
721
  body = fileBody;
720
- body.append("cacheControl", options.cacheControl);
722
+ if (!body.has("cacheControl")) body.append("cacheControl", options.cacheControl);
723
+ if (metadata && !body.has("metadata")) body.append("metadata", _this3.encodeMetadata(metadata));
721
724
  } else {
722
725
  body = fileBody;
723
726
  headers["cache-control"] = `max-age=${options.cacheControl}`;
724
727
  headers["content-type"] = options.contentType;
728
+ if (metadata) headers["x-metadata"] = _this3.toBase64(_this3.encodeMetadata(metadata));
729
+ if ((typeof ReadableStream !== "undefined" && body instanceof ReadableStream || body && typeof body === "object" && "pipe" in body && typeof body.pipe === "function") && !options.duplex) options.duplex = "half";
725
730
  }
731
+ if (fileOptions === null || fileOptions === void 0 ? void 0 : fileOptions.headers) for (const [key, value] of Object.entries(fileOptions.headers)) headers = setHeader(headers, key, value);
726
732
  return {
727
733
  path: cleanPath,
728
- fullPath: (await put(_this3.fetch, url.toString(), body, { headers })).Key
734
+ fullPath: (await put(_this3.fetch, url.toString(), body, _objectSpread2({ headers }, (options === null || options === void 0 ? void 0 : options.duplex) ? { duplex: options.duplex } : {}))).Key
729
735
  };
730
736
  });
731
737
  }
@@ -1481,7 +1487,7 @@ var StorageFileApi = class extends BaseApiClient {
1481
1487
 
1482
1488
  //#endregion
1483
1489
  //#region src/lib/version.ts
1484
- const version = "3.0.0-next.1";
1490
+ const version = "3.0.0-next.11";
1485
1491
 
1486
1492
  //#endregion
1487
1493
  //#region src/lib/constants.ts
@@ -1807,7 +1813,7 @@ var StorageAnalyticsClient = class extends BaseApiClient {
1807
1813
  * ```typescript
1808
1814
  * import { createClient } from '@supabase/supabase-js'
1809
1815
  *
1810
- * const supabase = createClient('https://xyzcompany.supabase.co', 'publishable-or-anon-key')
1816
+ * const supabase = createClient('https://xyzcompany.supabase.co', 'your-publishable-key')
1811
1817
  * const { data, error } = await supabase.storage.analytics.listBuckets()
1812
1818
  * ```
1813
1819
  *
@@ -2342,7 +2348,7 @@ var StorageVectorsClient = class extends VectorBucketApi {
2342
2348
  * ```typescript
2343
2349
  * import { createClient } from '@supabase/supabase-js'
2344
2350
  *
2345
- * const supabase = createClient('https://xyzcompany.supabase.co', 'publishable-or-anon-key')
2351
+ * const supabase = createClient('https://xyzcompany.supabase.co', 'your-publishable-key')
2346
2352
  * const bucket = supabase.storage.vectors.from('embeddings-prod')
2347
2353
  * ```
2348
2354
  *
@@ -2839,7 +2845,7 @@ var StorageClient = class extends StorageBucketApi {
2839
2845
  * ```ts
2840
2846
  * import { createClient } from '@supabase/supabase-js'
2841
2847
  *
2842
- * const supabase = createClient('https://xyzcompany.supabase.co', 'publishable-or-anon-key')
2848
+ * const supabase = createClient('https://xyzcompany.supabase.co', 'your-publishable-key')
2843
2849
  * const avatars = supabase.storage.from('avatars')
2844
2850
  * ```
2845
2851
  *
@@ -2848,7 +2854,7 @@ var StorageClient = class extends StorageBucketApi {
2848
2854
  * import { StorageClient } from '@supabase/storage-js'
2849
2855
  *
2850
2856
  * const storage = new StorageClient('https://xyzcompany.supabase.co/storage/v1', {
2851
- * apikey: 'publishable-or-anon-key',
2857
+ * apikey: 'your-publishable-key',
2852
2858
  * })
2853
2859
  * const avatars = storage.from('avatars')
2854
2860
  * ```