@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
|
@@ -16,6 +16,8 @@ export default class StorageFileApi {
|
|
|
16
16
|
}, bucketId?: string, fetch?: Fetch);
|
|
17
17
|
/**
|
|
18
18
|
* Enable throwing errors instead of returning them.
|
|
19
|
+
*
|
|
20
|
+
* @category File Buckets
|
|
19
21
|
*/
|
|
20
22
|
throwOnError(): this;
|
|
21
23
|
/**
|
|
@@ -29,8 +31,46 @@ export default class StorageFileApi {
|
|
|
29
31
|
/**
|
|
30
32
|
* Uploads a file to an existing bucket.
|
|
31
33
|
*
|
|
34
|
+
* @category File Buckets
|
|
32
35
|
* @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.
|
|
33
36
|
* @param fileBody The body of the file to be stored in the bucket.
|
|
37
|
+
* @param fileOptions Optional file upload options including cacheControl, contentType, upsert, and metadata.
|
|
38
|
+
* @returns Promise with file path and id or error
|
|
39
|
+
*
|
|
40
|
+
* @example Upload file
|
|
41
|
+
* ```js
|
|
42
|
+
* const avatarFile = event.target.files[0]
|
|
43
|
+
* const { data, error } = await supabase
|
|
44
|
+
* .storage
|
|
45
|
+
* .from('avatars')
|
|
46
|
+
* .upload('public/avatar1.png', avatarFile, {
|
|
47
|
+
* cacheControl: '3600',
|
|
48
|
+
* upsert: false
|
|
49
|
+
* })
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* Response:
|
|
53
|
+
* ```json
|
|
54
|
+
* {
|
|
55
|
+
* "data": {
|
|
56
|
+
* "path": "public/avatar1.png",
|
|
57
|
+
* "fullPath": "avatars/public/avatar1.png"
|
|
58
|
+
* },
|
|
59
|
+
* "error": null
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @example Upload file using `ArrayBuffer` from base64 file data
|
|
64
|
+
* ```js
|
|
65
|
+
* import { decode } from 'base64-arraybuffer'
|
|
66
|
+
*
|
|
67
|
+
* const { data, error } = await supabase
|
|
68
|
+
* .storage
|
|
69
|
+
* .from('avatars')
|
|
70
|
+
* .upload('public/avatar1.png', decode('base64FileData'), {
|
|
71
|
+
* contentType: 'image/png'
|
|
72
|
+
* })
|
|
73
|
+
* ```
|
|
34
74
|
*/
|
|
35
75
|
upload(path: string, fileBody: FileBody, fileOptions?: FileOptions): Promise<{
|
|
36
76
|
data: {
|
|
@@ -45,9 +85,32 @@ export default class StorageFileApi {
|
|
|
45
85
|
}>;
|
|
46
86
|
/**
|
|
47
87
|
* Upload a file with a token generated from `createSignedUploadUrl`.
|
|
88
|
+
*
|
|
89
|
+
* @category File Buckets
|
|
48
90
|
* @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.
|
|
49
91
|
* @param token The token generated from `createSignedUploadUrl`
|
|
50
92
|
* @param fileBody The body of the file to be stored in the bucket.
|
|
93
|
+
* @param fileOptions Optional file upload options including cacheControl and contentType.
|
|
94
|
+
* @returns Promise with file path and full path or error
|
|
95
|
+
*
|
|
96
|
+
* @example Upload to a signed URL
|
|
97
|
+
* ```js
|
|
98
|
+
* const { data, error } = await supabase
|
|
99
|
+
* .storage
|
|
100
|
+
* .from('avatars')
|
|
101
|
+
* .uploadToSignedUrl('folder/cat.jpg', 'token-from-createSignedUploadUrl', file)
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* Response:
|
|
105
|
+
* ```json
|
|
106
|
+
* {
|
|
107
|
+
* "data": {
|
|
108
|
+
* "path": "folder/cat.jpg",
|
|
109
|
+
* "fullPath": "avatars/folder/cat.jpg"
|
|
110
|
+
* },
|
|
111
|
+
* "error": null
|
|
112
|
+
* }
|
|
113
|
+
* ```
|
|
51
114
|
*/
|
|
52
115
|
uploadToSignedUrl(path: string, token: string, fileBody: FileBody, fileOptions?: FileOptions): Promise<{
|
|
53
116
|
data: {
|
|
@@ -63,8 +126,31 @@ export default class StorageFileApi {
|
|
|
63
126
|
* Creates a signed upload URL.
|
|
64
127
|
* Signed upload URLs can be used to upload files to the bucket without further authentication.
|
|
65
128
|
* They are valid for 2 hours.
|
|
129
|
+
*
|
|
130
|
+
* @category File Buckets
|
|
66
131
|
* @param path The file path, including the current file name. For example `folder/image.png`.
|
|
67
132
|
* @param options.upsert If set to true, allows the file to be overwritten if it already exists.
|
|
133
|
+
* @returns Promise with signed upload URL, token, and path or error
|
|
134
|
+
*
|
|
135
|
+
* @example Create Signed Upload URL
|
|
136
|
+
* ```js
|
|
137
|
+
* const { data, error } = await supabase
|
|
138
|
+
* .storage
|
|
139
|
+
* .from('avatars')
|
|
140
|
+
* .createSignedUploadUrl('folder/cat.jpg')
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* Response:
|
|
144
|
+
* ```json
|
|
145
|
+
* {
|
|
146
|
+
* "data": {
|
|
147
|
+
* "signedUrl": "https://example.supabase.co/storage/v1/object/upload/sign/avatars/folder/cat.jpg?token=<TOKEN>",
|
|
148
|
+
* "path": "folder/cat.jpg",
|
|
149
|
+
* "token": "<TOKEN>"
|
|
150
|
+
* },
|
|
151
|
+
* "error": null
|
|
152
|
+
* }
|
|
153
|
+
* ```
|
|
68
154
|
*/
|
|
69
155
|
createSignedUploadUrl(path: string, options?: {
|
|
70
156
|
upsert: boolean;
|
|
@@ -82,8 +168,46 @@ export default class StorageFileApi {
|
|
|
82
168
|
/**
|
|
83
169
|
* Replaces an existing file at the specified path with a new one.
|
|
84
170
|
*
|
|
171
|
+
* @category File Buckets
|
|
85
172
|
* @param path The relative file path. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to update.
|
|
86
173
|
* @param fileBody The body of the file to be stored in the bucket.
|
|
174
|
+
* @param fileOptions Optional file upload options including cacheControl, contentType, upsert, and metadata.
|
|
175
|
+
* @returns Promise with file path and id or error
|
|
176
|
+
*
|
|
177
|
+
* @example Update file
|
|
178
|
+
* ```js
|
|
179
|
+
* const avatarFile = event.target.files[0]
|
|
180
|
+
* const { data, error } = await supabase
|
|
181
|
+
* .storage
|
|
182
|
+
* .from('avatars')
|
|
183
|
+
* .update('public/avatar1.png', avatarFile, {
|
|
184
|
+
* cacheControl: '3600',
|
|
185
|
+
* upsert: true
|
|
186
|
+
* })
|
|
187
|
+
* ```
|
|
188
|
+
*
|
|
189
|
+
* Response:
|
|
190
|
+
* ```json
|
|
191
|
+
* {
|
|
192
|
+
* "data": {
|
|
193
|
+
* "path": "public/avatar1.png",
|
|
194
|
+
* "fullPath": "avatars/public/avatar1.png"
|
|
195
|
+
* },
|
|
196
|
+
* "error": null
|
|
197
|
+
* }
|
|
198
|
+
* ```
|
|
199
|
+
*
|
|
200
|
+
* @example Update file using `ArrayBuffer` from base64 file data
|
|
201
|
+
* ```js
|
|
202
|
+
* import {decode} from 'base64-arraybuffer'
|
|
203
|
+
*
|
|
204
|
+
* const { data, error } = await supabase
|
|
205
|
+
* .storage
|
|
206
|
+
* .from('avatars')
|
|
207
|
+
* .update('public/avatar1.png', decode('base64FileData'), {
|
|
208
|
+
* contentType: 'image/png'
|
|
209
|
+
* })
|
|
210
|
+
* ```
|
|
87
211
|
*/
|
|
88
212
|
update(path: string, fileBody: ArrayBuffer | ArrayBufferView | Blob | Buffer | File | FormData | NodeJS.ReadableStream | ReadableStream<Uint8Array> | URLSearchParams | string, fileOptions?: FileOptions): Promise<{
|
|
89
213
|
data: {
|
|
@@ -99,9 +223,29 @@ export default class StorageFileApi {
|
|
|
99
223
|
/**
|
|
100
224
|
* Moves an existing file to a new path in the same bucket.
|
|
101
225
|
*
|
|
226
|
+
* @category File Buckets
|
|
102
227
|
* @param fromPath The original file path, including the current file name. For example `folder/image.png`.
|
|
103
228
|
* @param toPath The new file path, including the new file name. For example `folder/image-new.png`.
|
|
104
229
|
* @param options The destination options.
|
|
230
|
+
* @returns Promise with success message or error
|
|
231
|
+
*
|
|
232
|
+
* @example Move file
|
|
233
|
+
* ```js
|
|
234
|
+
* const { data, error } = await supabase
|
|
235
|
+
* .storage
|
|
236
|
+
* .from('avatars')
|
|
237
|
+
* .move('public/avatar1.png', 'private/avatar2.png')
|
|
238
|
+
* ```
|
|
239
|
+
*
|
|
240
|
+
* Response:
|
|
241
|
+
* ```json
|
|
242
|
+
* {
|
|
243
|
+
* "data": {
|
|
244
|
+
* "message": "Successfully moved"
|
|
245
|
+
* },
|
|
246
|
+
* "error": null
|
|
247
|
+
* }
|
|
248
|
+
* ```
|
|
105
249
|
*/
|
|
106
250
|
move(fromPath: string, toPath: string, options?: DestinationOptions): Promise<{
|
|
107
251
|
data: {
|
|
@@ -115,9 +259,29 @@ export default class StorageFileApi {
|
|
|
115
259
|
/**
|
|
116
260
|
* Copies an existing file to a new path in the same bucket.
|
|
117
261
|
*
|
|
262
|
+
* @category File Buckets
|
|
118
263
|
* @param fromPath The original file path, including the current file name. For example `folder/image.png`.
|
|
119
264
|
* @param toPath The new file path, including the new file name. For example `folder/image-copy.png`.
|
|
120
265
|
* @param options The destination options.
|
|
266
|
+
* @returns Promise with copied file path or error
|
|
267
|
+
*
|
|
268
|
+
* @example Copy file
|
|
269
|
+
* ```js
|
|
270
|
+
* const { data, error } = await supabase
|
|
271
|
+
* .storage
|
|
272
|
+
* .from('avatars')
|
|
273
|
+
* .copy('public/avatar1.png', 'private/avatar2.png')
|
|
274
|
+
* ```
|
|
275
|
+
*
|
|
276
|
+
* Response:
|
|
277
|
+
* ```json
|
|
278
|
+
* {
|
|
279
|
+
* "data": {
|
|
280
|
+
* "path": "avatars/private/avatar2.png"
|
|
281
|
+
* },
|
|
282
|
+
* "error": null
|
|
283
|
+
* }
|
|
284
|
+
* ```
|
|
121
285
|
*/
|
|
122
286
|
copy(fromPath: string, toPath: string, options?: DestinationOptions): Promise<{
|
|
123
287
|
data: {
|
|
@@ -131,10 +295,53 @@ export default class StorageFileApi {
|
|
|
131
295
|
/**
|
|
132
296
|
* Creates a signed URL. Use a signed URL to share a file for a fixed amount of time.
|
|
133
297
|
*
|
|
298
|
+
* @category File Buckets
|
|
134
299
|
* @param path The file path, including the current file name. For example `folder/image.png`.
|
|
135
300
|
* @param expiresIn The number of seconds until the signed URL expires. For example, `60` for a URL which is valid for one minute.
|
|
136
301
|
* @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.
|
|
137
302
|
* @param options.transform Transform the asset before serving it to the client.
|
|
303
|
+
* @returns Promise with signed URL or error
|
|
304
|
+
*
|
|
305
|
+
* @example Create Signed URL
|
|
306
|
+
* ```js
|
|
307
|
+
* const { data, error } = await supabase
|
|
308
|
+
* .storage
|
|
309
|
+
* .from('avatars')
|
|
310
|
+
* .createSignedUrl('folder/avatar1.png', 60)
|
|
311
|
+
* ```
|
|
312
|
+
*
|
|
313
|
+
* Response:
|
|
314
|
+
* ```json
|
|
315
|
+
* {
|
|
316
|
+
* "data": {
|
|
317
|
+
* "signedUrl": "https://example.supabase.co/storage/v1/object/sign/avatars/folder/avatar1.png?token=<TOKEN>"
|
|
318
|
+
* },
|
|
319
|
+
* "error": null
|
|
320
|
+
* }
|
|
321
|
+
* ```
|
|
322
|
+
*
|
|
323
|
+
* @example Create a signed URL for an asset with transformations
|
|
324
|
+
* ```js
|
|
325
|
+
* const { data } = await supabase
|
|
326
|
+
* .storage
|
|
327
|
+
* .from('avatars')
|
|
328
|
+
* .createSignedUrl('folder/avatar1.png', 60, {
|
|
329
|
+
* transform: {
|
|
330
|
+
* width: 100,
|
|
331
|
+
* height: 100,
|
|
332
|
+
* }
|
|
333
|
+
* })
|
|
334
|
+
* ```
|
|
335
|
+
*
|
|
336
|
+
* @example Create a signed URL which triggers the download of the asset
|
|
337
|
+
* ```js
|
|
338
|
+
* const { data } = await supabase
|
|
339
|
+
* .storage
|
|
340
|
+
* .from('avatars')
|
|
341
|
+
* .createSignedUrl('folder/avatar1.png', 60, {
|
|
342
|
+
* download: true,
|
|
343
|
+
* })
|
|
344
|
+
* ```
|
|
138
345
|
*/
|
|
139
346
|
createSignedUrl(path: string, expiresIn: number, options?: {
|
|
140
347
|
download?: string | boolean;
|
|
@@ -151,9 +358,40 @@ export default class StorageFileApi {
|
|
|
151
358
|
/**
|
|
152
359
|
* Creates multiple signed URLs. Use a signed URL to share a file for a fixed amount of time.
|
|
153
360
|
*
|
|
361
|
+
* @category File Buckets
|
|
154
362
|
* @param paths The file paths to be downloaded, including the current file names. For example `['folder/image.png', 'folder2/image2.png']`.
|
|
155
363
|
* @param expiresIn The number of seconds until the signed URLs expire. For example, `60` for URLs which are valid for one minute.
|
|
156
364
|
* @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.
|
|
365
|
+
* @returns Promise with array of signed URLs or error
|
|
366
|
+
*
|
|
367
|
+
* @example Create Signed URLs
|
|
368
|
+
* ```js
|
|
369
|
+
* const { data, error } = await supabase
|
|
370
|
+
* .storage
|
|
371
|
+
* .from('avatars')
|
|
372
|
+
* .createSignedUrls(['folder/avatar1.png', 'folder/avatar2.png'], 60)
|
|
373
|
+
* ```
|
|
374
|
+
*
|
|
375
|
+
* Response:
|
|
376
|
+
* ```json
|
|
377
|
+
* {
|
|
378
|
+
* "data": [
|
|
379
|
+
* {
|
|
380
|
+
* "error": null,
|
|
381
|
+
* "path": "folder/avatar1.png",
|
|
382
|
+
* "signedURL": "/object/sign/avatars/folder/avatar1.png?token=<TOKEN>",
|
|
383
|
+
* "signedUrl": "https://example.supabase.co/storage/v1/object/sign/avatars/folder/avatar1.png?token=<TOKEN>"
|
|
384
|
+
* },
|
|
385
|
+
* {
|
|
386
|
+
* "error": null,
|
|
387
|
+
* "path": "folder/avatar2.png",
|
|
388
|
+
* "signedURL": "/object/sign/avatars/folder/avatar2.png?token=<TOKEN>",
|
|
389
|
+
* "signedUrl": "https://example.supabase.co/storage/v1/object/sign/avatars/folder/avatar2.png?token=<TOKEN>"
|
|
390
|
+
* }
|
|
391
|
+
* ],
|
|
392
|
+
* "error": null
|
|
393
|
+
* }
|
|
394
|
+
* ```
|
|
157
395
|
*/
|
|
158
396
|
createSignedUrls(paths: string[], expiresIn: number, options?: {
|
|
159
397
|
download: string | boolean;
|
|
@@ -171,15 +409,58 @@ export default class StorageFileApi {
|
|
|
171
409
|
/**
|
|
172
410
|
* Downloads a file from a private bucket. For public buckets, make a request to the URL returned from `getPublicUrl` instead.
|
|
173
411
|
*
|
|
412
|
+
* @category File Buckets
|
|
174
413
|
* @param path The full path and file name of the file to be downloaded. For example `folder/image.png`.
|
|
175
414
|
* @param options.transform Transform the asset before serving it to the client.
|
|
415
|
+
* @returns BlobDownloadBuilder instance for downloading the file
|
|
416
|
+
*
|
|
417
|
+
* @example Download file
|
|
418
|
+
* ```js
|
|
419
|
+
* const { data, error } = await supabase
|
|
420
|
+
* .storage
|
|
421
|
+
* .from('avatars')
|
|
422
|
+
* .download('folder/avatar1.png')
|
|
423
|
+
* ```
|
|
424
|
+
*
|
|
425
|
+
* Response:
|
|
426
|
+
* ```json
|
|
427
|
+
* {
|
|
428
|
+
* "data": <BLOB>,
|
|
429
|
+
* "error": null
|
|
430
|
+
* }
|
|
431
|
+
* ```
|
|
432
|
+
*
|
|
433
|
+
* @example Download file with transformations
|
|
434
|
+
* ```js
|
|
435
|
+
* const { data, error } = await supabase
|
|
436
|
+
* .storage
|
|
437
|
+
* .from('avatars')
|
|
438
|
+
* .download('folder/avatar1.png', {
|
|
439
|
+
* transform: {
|
|
440
|
+
* width: 100,
|
|
441
|
+
* height: 100,
|
|
442
|
+
* quality: 80
|
|
443
|
+
* }
|
|
444
|
+
* })
|
|
445
|
+
* ```
|
|
176
446
|
*/
|
|
177
447
|
download<Options extends {
|
|
178
448
|
transform?: TransformOptions;
|
|
179
449
|
}>(path: string, options?: Options): BlobDownloadBuilder;
|
|
180
450
|
/**
|
|
181
451
|
* Retrieves the details of an existing file.
|
|
182
|
-
*
|
|
452
|
+
*
|
|
453
|
+
* @category File Buckets
|
|
454
|
+
* @param path The file path, including the file name. For example `folder/image.png`.
|
|
455
|
+
* @returns Promise with file metadata or error
|
|
456
|
+
*
|
|
457
|
+
* @example Get file info
|
|
458
|
+
* ```js
|
|
459
|
+
* const { data, error } = await supabase
|
|
460
|
+
* .storage
|
|
461
|
+
* .from('avatars')
|
|
462
|
+
* .info('folder/avatar1.png')
|
|
463
|
+
* ```
|
|
183
464
|
*/
|
|
184
465
|
info(path: string): Promise<{
|
|
185
466
|
data: Camelize<FileObjectV2>;
|
|
@@ -190,7 +471,18 @@ export default class StorageFileApi {
|
|
|
190
471
|
}>;
|
|
191
472
|
/**
|
|
192
473
|
* Checks the existence of a file.
|
|
193
|
-
*
|
|
474
|
+
*
|
|
475
|
+
* @category File Buckets
|
|
476
|
+
* @param path The file path, including the file name. For example `folder/image.png`.
|
|
477
|
+
* @returns Promise with boolean indicating file existence or error
|
|
478
|
+
*
|
|
479
|
+
* @example Check file existence
|
|
480
|
+
* ```js
|
|
481
|
+
* const { data, error } = await supabase
|
|
482
|
+
* .storage
|
|
483
|
+
* .from('avatars')
|
|
484
|
+
* .exists('folder/avatar1.png')
|
|
485
|
+
* ```
|
|
194
486
|
*/
|
|
195
487
|
exists(path: string): Promise<{
|
|
196
488
|
data: boolean;
|
|
@@ -203,9 +495,51 @@ export default class StorageFileApi {
|
|
|
203
495
|
* 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.
|
|
204
496
|
* 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.
|
|
205
497
|
*
|
|
498
|
+
* @category File Buckets
|
|
206
499
|
* @param path The path and name of the file to generate the public URL for. For example `folder/image.png`.
|
|
207
500
|
* @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.
|
|
208
501
|
* @param options.transform Transform the asset before serving it to the client.
|
|
502
|
+
* @returns Object with public URL
|
|
503
|
+
*
|
|
504
|
+
* @example Returns the URL for an asset in a public bucket
|
|
505
|
+
* ```js
|
|
506
|
+
* const { data } = supabase
|
|
507
|
+
* .storage
|
|
508
|
+
* .from('public-bucket')
|
|
509
|
+
* .getPublicUrl('folder/avatar1.png')
|
|
510
|
+
* ```
|
|
511
|
+
*
|
|
512
|
+
* Response:
|
|
513
|
+
* ```json
|
|
514
|
+
* {
|
|
515
|
+
* "data": {
|
|
516
|
+
* "publicUrl": "https://example.supabase.co/storage/v1/object/public/public-bucket/folder/avatar1.png"
|
|
517
|
+
* }
|
|
518
|
+
* }
|
|
519
|
+
* ```
|
|
520
|
+
*
|
|
521
|
+
* @example Returns the URL for an asset in a public bucket with transformations
|
|
522
|
+
* ```js
|
|
523
|
+
* const { data } = supabase
|
|
524
|
+
* .storage
|
|
525
|
+
* .from('public-bucket')
|
|
526
|
+
* .getPublicUrl('folder/avatar1.png', {
|
|
527
|
+
* transform: {
|
|
528
|
+
* width: 100,
|
|
529
|
+
* height: 100,
|
|
530
|
+
* }
|
|
531
|
+
* })
|
|
532
|
+
* ```
|
|
533
|
+
*
|
|
534
|
+
* @example Returns the URL which triggers the download of an asset in a public bucket
|
|
535
|
+
* ```js
|
|
536
|
+
* const { data } = supabase
|
|
537
|
+
* .storage
|
|
538
|
+
* .from('public-bucket')
|
|
539
|
+
* .getPublicUrl('folder/avatar1.png', {
|
|
540
|
+
* download: true,
|
|
541
|
+
* })
|
|
542
|
+
* ```
|
|
209
543
|
*/
|
|
210
544
|
getPublicUrl(path: string, options?: {
|
|
211
545
|
download?: string | boolean;
|
|
@@ -218,7 +552,25 @@ export default class StorageFileApi {
|
|
|
218
552
|
/**
|
|
219
553
|
* Deletes files within the same bucket
|
|
220
554
|
*
|
|
555
|
+
* @category File Buckets
|
|
221
556
|
* @param paths An array of files to delete, including the path and file name. For example [`'folder/image.png'`].
|
|
557
|
+
* @returns Promise with list of deleted files or error
|
|
558
|
+
*
|
|
559
|
+
* @example Delete file
|
|
560
|
+
* ```js
|
|
561
|
+
* const { data, error } = await supabase
|
|
562
|
+
* .storage
|
|
563
|
+
* .from('avatars')
|
|
564
|
+
* .remove(['folder/avatar1.png'])
|
|
565
|
+
* ```
|
|
566
|
+
*
|
|
567
|
+
* Response:
|
|
568
|
+
* ```json
|
|
569
|
+
* {
|
|
570
|
+
* "data": [],
|
|
571
|
+
* "error": null
|
|
572
|
+
* }
|
|
573
|
+
* ```
|
|
222
574
|
*/
|
|
223
575
|
remove(paths: string[]): Promise<{
|
|
224
576
|
data: FileObject[];
|
|
@@ -238,8 +590,62 @@ export default class StorageFileApi {
|
|
|
238
590
|
*/
|
|
239
591
|
/**
|
|
240
592
|
* Lists all the files and folders within a path of the bucket.
|
|
593
|
+
*
|
|
594
|
+
* @category File Buckets
|
|
241
595
|
* @param path The folder path.
|
|
242
596
|
* @param options Search options including limit (defaults to 100), offset, sortBy, and search
|
|
597
|
+
* @param parameters Optional fetch parameters including signal for cancellation
|
|
598
|
+
* @returns Promise with list of files or error
|
|
599
|
+
*
|
|
600
|
+
* @example List files in a bucket
|
|
601
|
+
* ```js
|
|
602
|
+
* const { data, error } = await supabase
|
|
603
|
+
* .storage
|
|
604
|
+
* .from('avatars')
|
|
605
|
+
* .list('folder', {
|
|
606
|
+
* limit: 100,
|
|
607
|
+
* offset: 0,
|
|
608
|
+
* sortBy: { column: 'name', order: 'asc' },
|
|
609
|
+
* })
|
|
610
|
+
* ```
|
|
611
|
+
*
|
|
612
|
+
* Response:
|
|
613
|
+
* ```json
|
|
614
|
+
* {
|
|
615
|
+
* "data": [
|
|
616
|
+
* {
|
|
617
|
+
* "name": "avatar1.png",
|
|
618
|
+
* "id": "e668cf7f-821b-4a2f-9dce-7dfa5dd1cfd2",
|
|
619
|
+
* "updated_at": "2024-05-22T23:06:05.580Z",
|
|
620
|
+
* "created_at": "2024-05-22T23:04:34.443Z",
|
|
621
|
+
* "last_accessed_at": "2024-05-22T23:04:34.443Z",
|
|
622
|
+
* "metadata": {
|
|
623
|
+
* "eTag": "\"c5e8c553235d9af30ef4f6e280790b92\"",
|
|
624
|
+
* "size": 32175,
|
|
625
|
+
* "mimetype": "image/png",
|
|
626
|
+
* "cacheControl": "max-age=3600",
|
|
627
|
+
* "lastModified": "2024-05-22T23:06:05.574Z",
|
|
628
|
+
* "contentLength": 32175,
|
|
629
|
+
* "httpStatusCode": 200
|
|
630
|
+
* }
|
|
631
|
+
* }
|
|
632
|
+
* ],
|
|
633
|
+
* "error": null
|
|
634
|
+
* }
|
|
635
|
+
* ```
|
|
636
|
+
*
|
|
637
|
+
* @example Search files in a bucket
|
|
638
|
+
* ```js
|
|
639
|
+
* const { data, error } = await supabase
|
|
640
|
+
* .storage
|
|
641
|
+
* .from('avatars')
|
|
642
|
+
* .list('folder', {
|
|
643
|
+
* limit: 100,
|
|
644
|
+
* offset: 0,
|
|
645
|
+
* sortBy: { column: 'name', order: 'asc' },
|
|
646
|
+
* search: 'jon'
|
|
647
|
+
* })
|
|
648
|
+
* ```
|
|
243
649
|
*/
|
|
244
650
|
list(path?: string, options?: SearchOptions, parameters?: FetchParameters): Promise<{
|
|
245
651
|
data: FileObject[];
|
|
@@ -250,6 +656,8 @@ export default class StorageFileApi {
|
|
|
250
656
|
}>;
|
|
251
657
|
/**
|
|
252
658
|
* @experimental this method signature might change in the future
|
|
659
|
+
*
|
|
660
|
+
* @category File Buckets
|
|
253
661
|
* @param options search options
|
|
254
662
|
* @param parameters
|
|
255
663
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageFileApi.d.ts","sourceRoot":"","sources":["../../../src/packages/StorageFileApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,YAAY,EAAuB,MAAM,eAAe,CAAA;AACjF,OAAO,EAAE,KAAK,EAAgC,MAAM,cAAc,CAAA;AAElE,OAAO,EACL,UAAU,EACV,WAAW,EACX,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,cAAc,EACf,MAAM,cAAc,CAAA;AACrB,OAAO,mBAAmB,MAAM,uBAAuB,CAAA;AAiBvD,KAAK,QAAQ,GACT,WAAW,GACX,eAAe,GACf,IAAI,GACJ,MAAM,GACN,IAAI,GACJ,QAAQ,GACR,MAAM,CAAC,cAAc,GACrB,cAAc,CAAC,UAAU,CAAC,GAC1B,eAAe,GACf,MAAM,CAAA;AAEV,MAAM,CAAC,OAAO,OAAO,cAAc;IACjC,SAAS,CAAC,GAAG,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IAC5C,SAAS,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC3B,SAAS,CAAC,KAAK,EAAE,KAAK,CAAA;IACtB,SAAS,CAAC,kBAAkB,UAAQ;gBAGlC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAO,EACvC,QAAQ,CAAC,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,KAAK;IAQf
|
|
1
|
+
{"version":3,"file":"StorageFileApi.d.ts","sourceRoot":"","sources":["../../../src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