@supabase/storage-js 2.81.2-canary.3 → 2.82.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 +10 -0
- package/dist/main/StorageClient.d.ts +15 -1
- package/dist/main/StorageClient.d.ts.map +1 -1
- package/dist/main/StorageClient.js +15 -1
- package/dist/main/StorageClient.js.map +1 -1
- package/dist/main/lib/vectors/StorageVectorsClient.d.ts +99 -18
- package/dist/main/lib/vectors/StorageVectorsClient.d.ts.map +1 -1
- package/dist/main/lib/vectors/StorageVectorsClient.js +95 -17
- package/dist/main/lib/vectors/StorageVectorsClient.js.map +1 -1
- package/dist/main/lib/vectors/VectorBucketApi.d.ts +35 -7
- package/dist/main/lib/vectors/VectorBucketApi.d.ts.map +1 -1
- package/dist/main/lib/vectors/VectorBucketApi.js +35 -7
- package/dist/main/lib/vectors/VectorBucketApi.js.map +1 -1
- package/dist/main/lib/vectors/VectorDataApi.d.ts +44 -8
- package/dist/main/lib/vectors/VectorDataApi.d.ts.map +1 -1
- package/dist/main/lib/vectors/VectorDataApi.js +44 -8
- package/dist/main/lib/vectors/VectorDataApi.js.map +1 -1
- package/dist/main/lib/vectors/VectorIndexApi.d.ts +43 -8
- package/dist/main/lib/vectors/VectorIndexApi.d.ts.map +1 -1
- package/dist/main/lib/vectors/VectorIndexApi.js +39 -7
- package/dist/main/lib/vectors/VectorIndexApi.js.map +1 -1
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.d.ts.map +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/main/lib/version.js.map +1 -1
- package/dist/main/packages/StorageAnalyticsApi.d.ts +77 -26
- package/dist/main/packages/StorageAnalyticsApi.d.ts.map +1 -1
- package/dist/main/packages/StorageAnalyticsApi.js +77 -26
- package/dist/main/packages/StorageAnalyticsApi.js.map +1 -1
- package/dist/main/packages/StorageBucketApi.d.ts +143 -1
- package/dist/main/packages/StorageBucketApi.d.ts.map +1 -1
- package/dist/main/packages/StorageBucketApi.js +143 -1
- package/dist/main/packages/StorageBucketApi.js.map +1 -1
- package/dist/main/packages/StorageFileApi.d.ts +410 -2
- package/dist/main/packages/StorageFileApi.d.ts.map +1 -1
- package/dist/main/packages/StorageFileApi.js +410 -2
- package/dist/main/packages/StorageFileApi.js.map +1 -1
- package/dist/module/StorageClient.d.ts +15 -1
- package/dist/module/StorageClient.d.ts.map +1 -1
- package/dist/module/StorageClient.js +15 -1
- package/dist/module/StorageClient.js.map +1 -1
- package/dist/module/lib/vectors/StorageVectorsClient.d.ts +99 -18
- package/dist/module/lib/vectors/StorageVectorsClient.d.ts.map +1 -1
- package/dist/module/lib/vectors/StorageVectorsClient.js +95 -17
- package/dist/module/lib/vectors/StorageVectorsClient.js.map +1 -1
- package/dist/module/lib/vectors/VectorBucketApi.d.ts +35 -7
- package/dist/module/lib/vectors/VectorBucketApi.d.ts.map +1 -1
- package/dist/module/lib/vectors/VectorBucketApi.js +35 -7
- package/dist/module/lib/vectors/VectorBucketApi.js.map +1 -1
- package/dist/module/lib/vectors/VectorDataApi.d.ts +44 -8
- package/dist/module/lib/vectors/VectorDataApi.d.ts.map +1 -1
- package/dist/module/lib/vectors/VectorDataApi.js +44 -8
- package/dist/module/lib/vectors/VectorDataApi.js.map +1 -1
- package/dist/module/lib/vectors/VectorIndexApi.d.ts +43 -8
- package/dist/module/lib/vectors/VectorIndexApi.d.ts.map +1 -1
- package/dist/module/lib/vectors/VectorIndexApi.js +39 -7
- package/dist/module/lib/vectors/VectorIndexApi.js.map +1 -1
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.d.ts.map +1 -1
- package/dist/module/lib/version.js +1 -1
- package/dist/module/lib/version.js.map +1 -1
- package/dist/module/packages/StorageAnalyticsApi.d.ts +77 -26
- package/dist/module/packages/StorageAnalyticsApi.d.ts.map +1 -1
- package/dist/module/packages/StorageAnalyticsApi.js +77 -26
- package/dist/module/packages/StorageAnalyticsApi.js.map +1 -1
- package/dist/module/packages/StorageBucketApi.d.ts +143 -1
- package/dist/module/packages/StorageBucketApi.d.ts.map +1 -1
- package/dist/module/packages/StorageBucketApi.js +143 -1
- package/dist/module/packages/StorageBucketApi.js.map +1 -1
- package/dist/module/packages/StorageFileApi.d.ts +410 -2
- package/dist/module/packages/StorageFileApi.d.ts.map +1 -1
- package/dist/module/packages/StorageFileApi.js +410 -2
- package/dist/module/packages/StorageFileApi.js.map +1 -1
- package/dist/tsconfig.module.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/umd/supabase.js +1 -1
- package/package.json +1 -1
- package/src/StorageClient.ts +15 -1
- package/src/lib/vectors/StorageVectorsClient.ts +99 -18
- package/src/lib/vectors/VectorBucketApi.ts +35 -7
- package/src/lib/vectors/VectorDataApi.ts +44 -8
- package/src/lib/vectors/VectorIndexApi.ts +43 -8
- package/src/lib/version.ts +1 -1
- package/src/packages/StorageAnalyticsApi.ts +77 -26
- package/src/packages/StorageBucketApi.ts +143 -1
- package/src/packages/StorageFileApi.ts +410 -2
|
@@ -63,6 +63,8 @@ export default class StorageFileApi {
|
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* Enable throwing errors instead of returning them.
|
|
66
|
+
*
|
|
67
|
+
* @category File Buckets
|
|
66
68
|
*/
|
|
67
69
|
public throwOnError(): this {
|
|
68
70
|
this.shouldThrowOnError = true
|
|
@@ -169,8 +171,46 @@ export default class StorageFileApi {
|
|
|
169
171
|
/**
|
|
170
172
|
* Uploads a file to an existing bucket.
|
|
171
173
|
*
|
|
174
|
+
* @category File Buckets
|
|
172
175
|
* @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.
|
|
173
176
|
* @param fileBody The body of the file to be stored in the bucket.
|
|
177
|
+
* @param fileOptions Optional file upload options including cacheControl, contentType, upsert, and metadata.
|
|
178
|
+
* @returns Promise with file path and id or error
|
|
179
|
+
*
|
|
180
|
+
* @example Upload file
|
|
181
|
+
* ```js
|
|
182
|
+
* const avatarFile = event.target.files[0]
|
|
183
|
+
* const { data, error } = await supabase
|
|
184
|
+
* .storage
|
|
185
|
+
* .from('avatars')
|
|
186
|
+
* .upload('public/avatar1.png', avatarFile, {
|
|
187
|
+
* cacheControl: '3600',
|
|
188
|
+
* upsert: false
|
|
189
|
+
* })
|
|
190
|
+
* ```
|
|
191
|
+
*
|
|
192
|
+
* Response:
|
|
193
|
+
* ```json
|
|
194
|
+
* {
|
|
195
|
+
* "data": {
|
|
196
|
+
* "path": "public/avatar1.png",
|
|
197
|
+
* "fullPath": "avatars/public/avatar1.png"
|
|
198
|
+
* },
|
|
199
|
+
* "error": null
|
|
200
|
+
* }
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* @example Upload file using `ArrayBuffer` from base64 file data
|
|
204
|
+
* ```js
|
|
205
|
+
* import { decode } from 'base64-arraybuffer'
|
|
206
|
+
*
|
|
207
|
+
* const { data, error } = await supabase
|
|
208
|
+
* .storage
|
|
209
|
+
* .from('avatars')
|
|
210
|
+
* .upload('public/avatar1.png', decode('base64FileData'), {
|
|
211
|
+
* contentType: 'image/png'
|
|
212
|
+
* })
|
|
213
|
+
* ```
|
|
174
214
|
*/
|
|
175
215
|
async upload(
|
|
176
216
|
path: string,
|
|
@@ -191,9 +231,32 @@ export default class StorageFileApi {
|
|
|
191
231
|
|
|
192
232
|
/**
|
|
193
233
|
* Upload a file with a token generated from `createSignedUploadUrl`.
|
|
234
|
+
*
|
|
235
|
+
* @category File Buckets
|
|
194
236
|
* @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.
|
|
195
237
|
* @param token The token generated from `createSignedUploadUrl`
|
|
196
238
|
* @param fileBody The body of the file to be stored in the bucket.
|
|
239
|
+
* @param fileOptions Optional file upload options including cacheControl and contentType.
|
|
240
|
+
* @returns Promise with file path and full path or error
|
|
241
|
+
*
|
|
242
|
+
* @example Upload to a signed URL
|
|
243
|
+
* ```js
|
|
244
|
+
* const { data, error } = await supabase
|
|
245
|
+
* .storage
|
|
246
|
+
* .from('avatars')
|
|
247
|
+
* .uploadToSignedUrl('folder/cat.jpg', 'token-from-createSignedUploadUrl', file)
|
|
248
|
+
* ```
|
|
249
|
+
*
|
|
250
|
+
* Response:
|
|
251
|
+
* ```json
|
|
252
|
+
* {
|
|
253
|
+
* "data": {
|
|
254
|
+
* "path": "folder/cat.jpg",
|
|
255
|
+
* "fullPath": "avatars/folder/cat.jpg"
|
|
256
|
+
* },
|
|
257
|
+
* "error": null
|
|
258
|
+
* }
|
|
259
|
+
* ```
|
|
197
260
|
*/
|
|
198
261
|
async uploadToSignedUrl(
|
|
199
262
|
path: string,
|
|
@@ -250,8 +313,31 @@ export default class StorageFileApi {
|
|
|
250
313
|
* Creates a signed upload URL.
|
|
251
314
|
* Signed upload URLs can be used to upload files to the bucket without further authentication.
|
|
252
315
|
* They are valid for 2 hours.
|
|
316
|
+
*
|
|
317
|
+
* @category File Buckets
|
|
253
318
|
* @param path The file path, including the current file name. For example `folder/image.png`.
|
|
254
319
|
* @param options.upsert If set to true, allows the file to be overwritten if it already exists.
|
|
320
|
+
* @returns Promise with signed upload URL, token, and path or error
|
|
321
|
+
*
|
|
322
|
+
* @example Create Signed Upload URL
|
|
323
|
+
* ```js
|
|
324
|
+
* const { data, error } = await supabase
|
|
325
|
+
* .storage
|
|
326
|
+
* .from('avatars')
|
|
327
|
+
* .createSignedUploadUrl('folder/cat.jpg')
|
|
328
|
+
* ```
|
|
329
|
+
*
|
|
330
|
+
* Response:
|
|
331
|
+
* ```json
|
|
332
|
+
* {
|
|
333
|
+
* "data": {
|
|
334
|
+
* "signedUrl": "https://example.supabase.co/storage/v1/object/upload/sign/avatars/folder/cat.jpg?token=<TOKEN>",
|
|
335
|
+
* "path": "folder/cat.jpg",
|
|
336
|
+
* "token": "<TOKEN>"
|
|
337
|
+
* },
|
|
338
|
+
* "error": null
|
|
339
|
+
* }
|
|
340
|
+
* ```
|
|
255
341
|
*/
|
|
256
342
|
async createSignedUploadUrl(
|
|
257
343
|
path: string,
|
|
@@ -306,8 +392,46 @@ export default class StorageFileApi {
|
|
|
306
392
|
/**
|
|
307
393
|
* Replaces an existing file at the specified path with a new one.
|
|
308
394
|
*
|
|
395
|
+
* @category File Buckets
|
|
309
396
|
* @param path The relative file path. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to update.
|
|
310
397
|
* @param fileBody The body of the file to be stored in the bucket.
|
|
398
|
+
* @param fileOptions Optional file upload options including cacheControl, contentType, upsert, and metadata.
|
|
399
|
+
* @returns Promise with file path and id or error
|
|
400
|
+
*
|
|
401
|
+
* @example Update file
|
|
402
|
+
* ```js
|
|
403
|
+
* const avatarFile = event.target.files[0]
|
|
404
|
+
* const { data, error } = await supabase
|
|
405
|
+
* .storage
|
|
406
|
+
* .from('avatars')
|
|
407
|
+
* .update('public/avatar1.png', avatarFile, {
|
|
408
|
+
* cacheControl: '3600',
|
|
409
|
+
* upsert: true
|
|
410
|
+
* })
|
|
411
|
+
* ```
|
|
412
|
+
*
|
|
413
|
+
* Response:
|
|
414
|
+
* ```json
|
|
415
|
+
* {
|
|
416
|
+
* "data": {
|
|
417
|
+
* "path": "public/avatar1.png",
|
|
418
|
+
* "fullPath": "avatars/public/avatar1.png"
|
|
419
|
+
* },
|
|
420
|
+
* "error": null
|
|
421
|
+
* }
|
|
422
|
+
* ```
|
|
423
|
+
*
|
|
424
|
+
* @example Update file using `ArrayBuffer` from base64 file data
|
|
425
|
+
* ```js
|
|
426
|
+
* import {decode} from 'base64-arraybuffer'
|
|
427
|
+
*
|
|
428
|
+
* const { data, error } = await supabase
|
|
429
|
+
* .storage
|
|
430
|
+
* .from('avatars')
|
|
431
|
+
* .update('public/avatar1.png', decode('base64FileData'), {
|
|
432
|
+
* contentType: 'image/png'
|
|
433
|
+
* })
|
|
434
|
+
* ```
|
|
311
435
|
*/
|
|
312
436
|
async update(
|
|
313
437
|
path: string,
|
|
@@ -339,9 +463,29 @@ export default class StorageFileApi {
|
|
|
339
463
|
/**
|
|
340
464
|
* Moves an existing file to a new path in the same bucket.
|
|
341
465
|
*
|
|
466
|
+
* @category File Buckets
|
|
342
467
|
* @param fromPath The original file path, including the current file name. For example `folder/image.png`.
|
|
343
468
|
* @param toPath The new file path, including the new file name. For example `folder/image-new.png`.
|
|
344
469
|
* @param options The destination options.
|
|
470
|
+
* @returns Promise with success message or error
|
|
471
|
+
*
|
|
472
|
+
* @example Move file
|
|
473
|
+
* ```js
|
|
474
|
+
* const { data, error } = await supabase
|
|
475
|
+
* .storage
|
|
476
|
+
* .from('avatars')
|
|
477
|
+
* .move('public/avatar1.png', 'private/avatar2.png')
|
|
478
|
+
* ```
|
|
479
|
+
*
|
|
480
|
+
* Response:
|
|
481
|
+
* ```json
|
|
482
|
+
* {
|
|
483
|
+
* "data": {
|
|
484
|
+
* "message": "Successfully moved"
|
|
485
|
+
* },
|
|
486
|
+
* "error": null
|
|
487
|
+
* }
|
|
488
|
+
* ```
|
|
345
489
|
*/
|
|
346
490
|
async move(
|
|
347
491
|
fromPath: string,
|
|
@@ -385,9 +529,29 @@ export default class StorageFileApi {
|
|
|
385
529
|
/**
|
|
386
530
|
* Copies an existing file to a new path in the same bucket.
|
|
387
531
|
*
|
|
532
|
+
* @category File Buckets
|
|
388
533
|
* @param fromPath The original file path, including the current file name. For example `folder/image.png`.
|
|
389
534
|
* @param toPath The new file path, including the new file name. For example `folder/image-copy.png`.
|
|
390
535
|
* @param options The destination options.
|
|
536
|
+
* @returns Promise with copied file path or error
|
|
537
|
+
*
|
|
538
|
+
* @example Copy file
|
|
539
|
+
* ```js
|
|
540
|
+
* const { data, error } = await supabase
|
|
541
|
+
* .storage
|
|
542
|
+
* .from('avatars')
|
|
543
|
+
* .copy('public/avatar1.png', 'private/avatar2.png')
|
|
544
|
+
* ```
|
|
545
|
+
*
|
|
546
|
+
* Response:
|
|
547
|
+
* ```json
|
|
548
|
+
* {
|
|
549
|
+
* "data": {
|
|
550
|
+
* "path": "avatars/private/avatar2.png"
|
|
551
|
+
* },
|
|
552
|
+
* "error": null
|
|
553
|
+
* }
|
|
554
|
+
* ```
|
|
391
555
|
*/
|
|
392
556
|
async copy(
|
|
393
557
|
fromPath: string,
|
|
@@ -431,10 +595,53 @@ export default class StorageFileApi {
|
|
|
431
595
|
/**
|
|
432
596
|
* Creates a signed URL. Use a signed URL to share a file for a fixed amount of time.
|
|
433
597
|
*
|
|
598
|
+
* @category File Buckets
|
|
434
599
|
* @param path The file path, including the current file name. For example `folder/image.png`.
|
|
435
600
|
* @param expiresIn The number of seconds until the signed URL expires. For example, `60` for a URL which is valid for one minute.
|
|
436
601
|
* @param options.download triggers the file as a download if set to true. Set this parameter as the name of the file if you want to trigger the download with a different filename.
|
|
437
602
|
* @param options.transform Transform the asset before serving it to the client.
|
|
603
|
+
* @returns Promise with signed URL or error
|
|
604
|
+
*
|
|
605
|
+
* @example Create Signed URL
|
|
606
|
+
* ```js
|
|
607
|
+
* const { data, error } = await supabase
|
|
608
|
+
* .storage
|
|
609
|
+
* .from('avatars')
|
|
610
|
+
* .createSignedUrl('folder/avatar1.png', 60)
|
|
611
|
+
* ```
|
|
612
|
+
*
|
|
613
|
+
* Response:
|
|
614
|
+
* ```json
|
|
615
|
+
* {
|
|
616
|
+
* "data": {
|
|
617
|
+
* "signedUrl": "https://example.supabase.co/storage/v1/object/sign/avatars/folder/avatar1.png?token=<TOKEN>"
|
|
618
|
+
* },
|
|
619
|
+
* "error": null
|
|
620
|
+
* }
|
|
621
|
+
* ```
|
|
622
|
+
*
|
|
623
|
+
* @example Create a signed URL for an asset with transformations
|
|
624
|
+
* ```js
|
|
625
|
+
* const { data } = await supabase
|
|
626
|
+
* .storage
|
|
627
|
+
* .from('avatars')
|
|
628
|
+
* .createSignedUrl('folder/avatar1.png', 60, {
|
|
629
|
+
* transform: {
|
|
630
|
+
* width: 100,
|
|
631
|
+
* height: 100,
|
|
632
|
+
* }
|
|
633
|
+
* })
|
|
634
|
+
* ```
|
|
635
|
+
*
|
|
636
|
+
* @example Create a signed URL which triggers the download of the asset
|
|
637
|
+
* ```js
|
|
638
|
+
* const { data } = await supabase
|
|
639
|
+
* .storage
|
|
640
|
+
* .from('avatars')
|
|
641
|
+
* .createSignedUrl('folder/avatar1.png', 60, {
|
|
642
|
+
* download: true,
|
|
643
|
+
* })
|
|
644
|
+
* ```
|
|
438
645
|
*/
|
|
439
646
|
async createSignedUrl(
|
|
440
647
|
path: string,
|
|
@@ -480,9 +687,40 @@ export default class StorageFileApi {
|
|
|
480
687
|
/**
|
|
481
688
|
* Creates multiple signed URLs. Use a signed URL to share a file for a fixed amount of time.
|
|
482
689
|
*
|
|
690
|
+
* @category File Buckets
|
|
483
691
|
* @param paths The file paths to be downloaded, including the current file names. For example `['folder/image.png', 'folder2/image2.png']`.
|
|
484
692
|
* @param expiresIn The number of seconds until the signed URLs expire. For example, `60` for URLs which are valid for one minute.
|
|
485
693
|
* @param options.download triggers the file as a download if set to true. Set this parameter as the name of the file if you want to trigger the download with a different filename.
|
|
694
|
+
* @returns Promise with array of signed URLs or error
|
|
695
|
+
*
|
|
696
|
+
* @example Create Signed URLs
|
|
697
|
+
* ```js
|
|
698
|
+
* const { data, error } = await supabase
|
|
699
|
+
* .storage
|
|
700
|
+
* .from('avatars')
|
|
701
|
+
* .createSignedUrls(['folder/avatar1.png', 'folder/avatar2.png'], 60)
|
|
702
|
+
* ```
|
|
703
|
+
*
|
|
704
|
+
* Response:
|
|
705
|
+
* ```json
|
|
706
|
+
* {
|
|
707
|
+
* "data": [
|
|
708
|
+
* {
|
|
709
|
+
* "error": null,
|
|
710
|
+
* "path": "folder/avatar1.png",
|
|
711
|
+
* "signedURL": "/object/sign/avatars/folder/avatar1.png?token=<TOKEN>",
|
|
712
|
+
* "signedUrl": "https://example.supabase.co/storage/v1/object/sign/avatars/folder/avatar1.png?token=<TOKEN>"
|
|
713
|
+
* },
|
|
714
|
+
* {
|
|
715
|
+
* "error": null,
|
|
716
|
+
* "path": "folder/avatar2.png",
|
|
717
|
+
* "signedURL": "/object/sign/avatars/folder/avatar2.png?token=<TOKEN>",
|
|
718
|
+
* "signedUrl": "https://example.supabase.co/storage/v1/object/sign/avatars/folder/avatar2.png?token=<TOKEN>"
|
|
719
|
+
* }
|
|
720
|
+
* ],
|
|
721
|
+
* "error": null
|
|
722
|
+
* }
|
|
723
|
+
* ```
|
|
486
724
|
*/
|
|
487
725
|
async createSignedUrls(
|
|
488
726
|
paths: string[],
|
|
@@ -533,8 +771,40 @@ export default class StorageFileApi {
|
|
|
533
771
|
/**
|
|
534
772
|
* Downloads a file from a private bucket. For public buckets, make a request to the URL returned from `getPublicUrl` instead.
|
|
535
773
|
*
|
|
774
|
+
* @category File Buckets
|
|
536
775
|
* @param path The full path and file name of the file to be downloaded. For example `folder/image.png`.
|
|
537
776
|
* @param options.transform Transform the asset before serving it to the client.
|
|
777
|
+
* @returns BlobDownloadBuilder instance for downloading the file
|
|
778
|
+
*
|
|
779
|
+
* @example Download file
|
|
780
|
+
* ```js
|
|
781
|
+
* const { data, error } = await supabase
|
|
782
|
+
* .storage
|
|
783
|
+
* .from('avatars')
|
|
784
|
+
* .download('folder/avatar1.png')
|
|
785
|
+
* ```
|
|
786
|
+
*
|
|
787
|
+
* Response:
|
|
788
|
+
* ```json
|
|
789
|
+
* {
|
|
790
|
+
* "data": <BLOB>,
|
|
791
|
+
* "error": null
|
|
792
|
+
* }
|
|
793
|
+
* ```
|
|
794
|
+
*
|
|
795
|
+
* @example Download file with transformations
|
|
796
|
+
* ```js
|
|
797
|
+
* const { data, error } = await supabase
|
|
798
|
+
* .storage
|
|
799
|
+
* .from('avatars')
|
|
800
|
+
* .download('folder/avatar1.png', {
|
|
801
|
+
* transform: {
|
|
802
|
+
* width: 100,
|
|
803
|
+
* height: 100,
|
|
804
|
+
* quality: 80
|
|
805
|
+
* }
|
|
806
|
+
* })
|
|
807
|
+
* ```
|
|
538
808
|
*/
|
|
539
809
|
download<Options extends { transform?: TransformOptions }>(
|
|
540
810
|
path: string,
|
|
@@ -555,7 +825,18 @@ export default class StorageFileApi {
|
|
|
555
825
|
|
|
556
826
|
/**
|
|
557
827
|
* Retrieves the details of an existing file.
|
|
558
|
-
*
|
|
828
|
+
*
|
|
829
|
+
* @category File Buckets
|
|
830
|
+
* @param path The file path, including the file name. For example `folder/image.png`.
|
|
831
|
+
* @returns Promise with file metadata or error
|
|
832
|
+
*
|
|
833
|
+
* @example Get file info
|
|
834
|
+
* ```js
|
|
835
|
+
* const { data, error } = await supabase
|
|
836
|
+
* .storage
|
|
837
|
+
* .from('avatars')
|
|
838
|
+
* .info('folder/avatar1.png')
|
|
839
|
+
* ```
|
|
559
840
|
*/
|
|
560
841
|
async info(path: string): Promise<
|
|
561
842
|
| {
|
|
@@ -589,7 +870,18 @@ export default class StorageFileApi {
|
|
|
589
870
|
|
|
590
871
|
/**
|
|
591
872
|
* Checks the existence of a file.
|
|
592
|
-
*
|
|
873
|
+
*
|
|
874
|
+
* @category File Buckets
|
|
875
|
+
* @param path The file path, including the file name. For example `folder/image.png`.
|
|
876
|
+
* @returns Promise with boolean indicating file existence or error
|
|
877
|
+
*
|
|
878
|
+
* @example Check file existence
|
|
879
|
+
* ```js
|
|
880
|
+
* const { data, error } = await supabase
|
|
881
|
+
* .storage
|
|
882
|
+
* .from('avatars')
|
|
883
|
+
* .exists('folder/avatar1.png')
|
|
884
|
+
* ```
|
|
593
885
|
*/
|
|
594
886
|
async exists(path: string): Promise<
|
|
595
887
|
| {
|
|
@@ -629,9 +921,51 @@ export default class StorageFileApi {
|
|
|
629
921
|
* A simple convenience function to get the URL for an asset in a public bucket. If you do not want to use this function, you can construct the public URL by concatenating the bucket URL with the path to the asset.
|
|
630
922
|
* This function does not verify if the bucket is public. If a public URL is created for a bucket which is not public, you will not be able to download the asset.
|
|
631
923
|
*
|
|
924
|
+
* @category File Buckets
|
|
632
925
|
* @param path The path and name of the file to generate the public URL for. For example `folder/image.png`.
|
|
633
926
|
* @param options.download Triggers the file as a download if set to true. Set this parameter as the name of the file if you want to trigger the download with a different filename.
|
|
634
927
|
* @param options.transform Transform the asset before serving it to the client.
|
|
928
|
+
* @returns Object with public URL
|
|
929
|
+
*
|
|
930
|
+
* @example Returns the URL for an asset in a public bucket
|
|
931
|
+
* ```js
|
|
932
|
+
* const { data } = supabase
|
|
933
|
+
* .storage
|
|
934
|
+
* .from('public-bucket')
|
|
935
|
+
* .getPublicUrl('folder/avatar1.png')
|
|
936
|
+
* ```
|
|
937
|
+
*
|
|
938
|
+
* Response:
|
|
939
|
+
* ```json
|
|
940
|
+
* {
|
|
941
|
+
* "data": {
|
|
942
|
+
* "publicUrl": "https://example.supabase.co/storage/v1/object/public/public-bucket/folder/avatar1.png"
|
|
943
|
+
* }
|
|
944
|
+
* }
|
|
945
|
+
* ```
|
|
946
|
+
*
|
|
947
|
+
* @example Returns the URL for an asset in a public bucket with transformations
|
|
948
|
+
* ```js
|
|
949
|
+
* const { data } = supabase
|
|
950
|
+
* .storage
|
|
951
|
+
* .from('public-bucket')
|
|
952
|
+
* .getPublicUrl('folder/avatar1.png', {
|
|
953
|
+
* transform: {
|
|
954
|
+
* width: 100,
|
|
955
|
+
* height: 100,
|
|
956
|
+
* }
|
|
957
|
+
* })
|
|
958
|
+
* ```
|
|
959
|
+
*
|
|
960
|
+
* @example Returns the URL which triggers the download of an asset in a public bucket
|
|
961
|
+
* ```js
|
|
962
|
+
* const { data } = supabase
|
|
963
|
+
* .storage
|
|
964
|
+
* .from('public-bucket')
|
|
965
|
+
* .getPublicUrl('folder/avatar1.png', {
|
|
966
|
+
* download: true,
|
|
967
|
+
* })
|
|
968
|
+
* ```
|
|
635
969
|
*/
|
|
636
970
|
getPublicUrl(
|
|
637
971
|
path: string,
|
|
@@ -669,7 +1003,25 @@ export default class StorageFileApi {
|
|
|
669
1003
|
/**
|
|
670
1004
|
* Deletes files within the same bucket
|
|
671
1005
|
*
|
|
1006
|
+
* @category File Buckets
|
|
672
1007
|
* @param paths An array of files to delete, including the path and file name. For example [`'folder/image.png'`].
|
|
1008
|
+
* @returns Promise with list of deleted files or error
|
|
1009
|
+
*
|
|
1010
|
+
* @example Delete file
|
|
1011
|
+
* ```js
|
|
1012
|
+
* const { data, error } = await supabase
|
|
1013
|
+
* .storage
|
|
1014
|
+
* .from('avatars')
|
|
1015
|
+
* .remove(['folder/avatar1.png'])
|
|
1016
|
+
* ```
|
|
1017
|
+
*
|
|
1018
|
+
* Response:
|
|
1019
|
+
* ```json
|
|
1020
|
+
* {
|
|
1021
|
+
* "data": [],
|
|
1022
|
+
* "error": null
|
|
1023
|
+
* }
|
|
1024
|
+
* ```
|
|
673
1025
|
*/
|
|
674
1026
|
async remove(paths: string[]): Promise<
|
|
675
1027
|
| {
|
|
@@ -766,8 +1118,62 @@ export default class StorageFileApi {
|
|
|
766
1118
|
|
|
767
1119
|
/**
|
|
768
1120
|
* Lists all the files and folders within a path of the bucket.
|
|
1121
|
+
*
|
|
1122
|
+
* @category File Buckets
|
|
769
1123
|
* @param path The folder path.
|
|
770
1124
|
* @param options Search options including limit (defaults to 100), offset, sortBy, and search
|
|
1125
|
+
* @param parameters Optional fetch parameters including signal for cancellation
|
|
1126
|
+
* @returns Promise with list of files or error
|
|
1127
|
+
*
|
|
1128
|
+
* @example List files in a bucket
|
|
1129
|
+
* ```js
|
|
1130
|
+
* const { data, error } = await supabase
|
|
1131
|
+
* .storage
|
|
1132
|
+
* .from('avatars')
|
|
1133
|
+
* .list('folder', {
|
|
1134
|
+
* limit: 100,
|
|
1135
|
+
* offset: 0,
|
|
1136
|
+
* sortBy: { column: 'name', order: 'asc' },
|
|
1137
|
+
* })
|
|
1138
|
+
* ```
|
|
1139
|
+
*
|
|
1140
|
+
* Response:
|
|
1141
|
+
* ```json
|
|
1142
|
+
* {
|
|
1143
|
+
* "data": [
|
|
1144
|
+
* {
|
|
1145
|
+
* "name": "avatar1.png",
|
|
1146
|
+
* "id": "e668cf7f-821b-4a2f-9dce-7dfa5dd1cfd2",
|
|
1147
|
+
* "updated_at": "2024-05-22T23:06:05.580Z",
|
|
1148
|
+
* "created_at": "2024-05-22T23:04:34.443Z",
|
|
1149
|
+
* "last_accessed_at": "2024-05-22T23:04:34.443Z",
|
|
1150
|
+
* "metadata": {
|
|
1151
|
+
* "eTag": "\"c5e8c553235d9af30ef4f6e280790b92\"",
|
|
1152
|
+
* "size": 32175,
|
|
1153
|
+
* "mimetype": "image/png",
|
|
1154
|
+
* "cacheControl": "max-age=3600",
|
|
1155
|
+
* "lastModified": "2024-05-22T23:06:05.574Z",
|
|
1156
|
+
* "contentLength": 32175,
|
|
1157
|
+
* "httpStatusCode": 200
|
|
1158
|
+
* }
|
|
1159
|
+
* }
|
|
1160
|
+
* ],
|
|
1161
|
+
* "error": null
|
|
1162
|
+
* }
|
|
1163
|
+
* ```
|
|
1164
|
+
*
|
|
1165
|
+
* @example Search files in a bucket
|
|
1166
|
+
* ```js
|
|
1167
|
+
* const { data, error } = await supabase
|
|
1168
|
+
* .storage
|
|
1169
|
+
* .from('avatars')
|
|
1170
|
+
* .list('folder', {
|
|
1171
|
+
* limit: 100,
|
|
1172
|
+
* offset: 0,
|
|
1173
|
+
* sortBy: { column: 'name', order: 'asc' },
|
|
1174
|
+
* search: 'jon'
|
|
1175
|
+
* })
|
|
1176
|
+
* ```
|
|
771
1177
|
*/
|
|
772
1178
|
async list(
|
|
773
1179
|
path?: string,
|
|
@@ -807,6 +1213,8 @@ export default class StorageFileApi {
|
|
|
807
1213
|
|
|
808
1214
|
/**
|
|
809
1215
|
* @experimental this method signature might change in the future
|
|
1216
|
+
*
|
|
1217
|
+
* @category File Buckets
|
|
810
1218
|
* @param options search options
|
|
811
1219
|
* @param parameters
|
|
812
1220
|
*/
|