@data-loom/storage-js 0.4.1 → 0.4.2-alpha.1

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
@@ -1,165 +1,479 @@
1
- # `storage-js`
1
+ # @data-loom/storage-js
2
2
 
3
- #### `This project is a modified derivative version based on @supabase/storage-js. The original project is licensed under the Apache License 2.0.`
3
+ Dataloom 存储服务 JavaScript SDK,基于 Supabase Storage 修改而来,提供了强大的文件存储和管理功能。
4
4
 
5
- <div align="center">
5
+ ## 功能特性
6
6
 
7
- [![pkg.pr.new](https://pkg.pr.new/badge/supabase/storage-js)](https://pkg.pr.new/~/supabase/storage-js)
7
+ - 📁 **文件上传和下载** - 支持多种文件格式的上传和下载
8
+ - 🔗 **签名URL** - 创建具有时效性的安全文件访问链接
9
+ - 🗑️ **文件管理** - 删除、列表等文件操作
10
+ - 🖼️ **图片转换** - 支持图片尺寸调整、质量优化等转换功能
11
+ - 📊 **批量操作** - 支持批量创建签名URL等批量操作
12
+ - 🔍 **文件搜索** - 支持文件搜索和分页
13
+ - 🛡️ **错误处理** - 完善的错误处理机制
8
14
 
9
- </div>
15
+ ## 安装
10
16
 
11
- JS Client library to interact with Supabase Storage.
17
+ ```bash
18
+ npm install @data-loom/storage-js
19
+ ```
12
20
 
13
- - Documentation: https://supabase.io/docs/reference/javascript/storage-createbucket
21
+ ## 快速开始
22
+
23
+ **默认推荐使用挂载在 @data-loom/js 中的 storage 接口。**
24
+ ```javascript
25
+ import { createClient } from '@data-loom/js';
26
+ const dataloom = createClient(url, key, workspace, {
27
+ global: {
28
+ brandName: 'your_brand_name',
29
+ appId: 'your_app_id',
30
+ enableDataloomLog: true,
31
+ requestRateLimit: 10,
32
+ onError: (error) => {
33
+ }
34
+ },
35
+ });
36
+ const { data, error } = await dataloom.storage.from('bucket_id').download('file_path');
37
+ ```
14
38
 
15
- ## Quick Start Guide
39
+ **或者可以独立使用 storage-js 包。**
40
+ ```javascript
41
+ import { StorageClient } from '@data-loom/storage-js'
42
+
43
+ // 独立初始化存储客户端
44
+ const storage = new StorageClient(
45
+ storageUrl,
46
+ customHeaders,
47
+ customFetch,
48
+ {
49
+ enableLogger: true,
50
+ appId: 'your-app-id',
51
+ onRequestError: (error) => console.error('请求错误:', error),
52
+ },
53
+ );
54
+
55
+ // 上传文件
56
+ const { data, error } = await storage.upload('folder/image.png', file);
57
+ if (error) {
58
+ console.error('上传失败:', error);
59
+ } else {
60
+ console.log('上传成功:', data);
61
+ }
62
+ ```
16
63
 
17
- ### Installing the module
64
+ ## API 接口文档
18
65
 
19
- ```bash
20
- npm install @supabase/storage-js
66
+ ### 构造函数
67
+
68
+ ```typescript
69
+ constructor(
70
+ url: string, // 存储服务URL
71
+ headers: { [key: string]: string } = {}, // 请求头
72
+ bucketId?: string, // 存储桶ID
73
+ appId?: string, // 应用ID
74
+ fetch?: Fetch, // 自定义fetch函数
75
+ loggerEnabled?: boolean, // 是否启用日志
76
+ onRequestError?: (error: OnRequestErrorType) => void // 请求错误回调
77
+ )
21
78
  ```
22
79
 
23
- ### Connecting to the storage backend
80
+ ### 文件上传
81
+
82
+ #### `upload(path, fileBody, fileOptions?)`
24
83
 
25
- ```js
26
- import { StorageClient } from '@supabase/storage-js'
84
+ 上传文件到指定的存储桶路径。
27
85
 
28
- const STORAGE_URL = 'https://<project_ref>.supabase.co/storage/v1'
29
- const SERVICE_KEY = '<service_role>' //! service key, not anon key
86
+ **参数:**
87
+ - `path` (string): 文件路径,格式为 `folder/subfolder/filename.png`
88
+ - `fileBody` (FileBody): 文件内容,支持多种格式
89
+ - `fileOptions` (FileOptions, 可选): 文件选项
30
90
 
31
- const storageClient = new StorageClient(STORAGE_URL, {
32
- apikey: SERVICE_KEY,
33
- Authorization: `Bearer ${SERVICE_KEY}`,
34
- })
91
+ **返回:**
92
+ ```typescript
93
+ {
94
+ data: UploadFileData; // 包含文件ID、路径、存储桶ID和下载URL
95
+ error: null;
96
+ } | {
97
+ data: null;
98
+ error: StorageError;
99
+ }
35
100
  ```
36
101
 
37
- ### Handling resources
102
+ **示例:**
103
+ ```javascript
104
+ const fileInput = document.getElementById('fileInput');
105
+ const file = fileInput.files[0];
38
106
 
39
- #### Handling Storage Buckets
107
+ const { data, error } = await storage.upload('avatars/user-123.jpg', file, {
108
+ cacheControl: '3600',
109
+ contentType: 'image/jpeg',
110
+ upsert: false
111
+ });
112
+ ```
40
113
 
41
- - Create a new Storage bucket:
114
+ #### `uploadFile(fileBody, fileOptions?)`
42
115
 
43
- ```js
44
- const { data, error } = await storageClient.createBucket(
45
- 'test_bucket', // Bucket name (must be unique)
46
- { public: false } // Bucket options
47
- )
48
- ```
116
+ 使用文件选项上传文件(推荐, 无需关注filePath)。
49
117
 
50
- - Retrieve the details of an existing Storage bucket:
118
+ **参数:**
119
+ - `fileBody` (FileBody): 文件内容
120
+ - `fileOptions` (FileOptionsV2, 可选): 文件选项,可指定 filePath 等
51
121
 
52
- ```js
53
- const { data, error } = await storageClient.getBucket('test_bucket')
54
- ```
122
+ **返回:** 同 `upload` 方法
55
123
 
56
- - Update a new Storage bucket:
124
+ **示例:**
125
+ ```javascript
126
+ const { data, error } = await storage.uploadFile(file, {
127
+ filePath: 'documents/report.pdf',
128
+ cacheControl: 3600,
129
+ contentType: 'application/pdf',
130
+ contentDisposition: 'attachment; filename="report.pdf"'
131
+ });
132
+ ```
57
133
 
58
- ```js
59
- const { data, error } = await storageClient.updateBucket(
60
- 'test_bucket', // Bucket name
61
- { public: false } // Bucket options
62
- )
63
- ```
134
+ ### 文件更新
64
135
 
65
- - Remove all objects inside a single bucket:
136
+ #### `update(path, fileBody, fileOptions?)`
66
137
 
67
- ```js
68
- const { data, error } = await storageClient.emptyBucket('test_bucket')
69
- ```
138
+ 替换指定路径的现有文件。
70
139
 
71
- - Delete an existing bucket (a bucket can't be deleted with existing objects inside it):
140
+ **参数:** `upload` 方法
72
141
 
73
- ```js
74
- const { data, error } = await storageClient.deleteBucket('test_bucket')
75
- ```
142
+ **返回:** 同 `upload` 方法
76
143
 
77
- - Retrieve the details of all Storage buckets within an existing project:
144
+ ### 创建签名URL
78
145
 
79
- ```js
80
- const { data, error } = await storageClient.listBuckets()
81
- ```
146
+ #### `createSignedUrl(path, expiresIn, options?)`
82
147
 
83
- #### Handling Files
148
+ 创建具有时效性的安全文件访问链接。
84
149
 
85
- - Upload a file to an existing bucket:
150
+ **参数:**
151
+ - `path` (string): 文件路径
152
+ - `expiresIn` (number): 过期时间(秒)
153
+ - `options` (object, 可选): 选项
154
+ - `download` (string | boolean): 是否触发下载,可指定文件名
155
+ - `transform` (TransformOptions): 图片转换选项
86
156
 
87
- ```js
88
- const fileBody = ... // load your file here
157
+ **返回:**
158
+ ```typescript
159
+ {
160
+ data: { signedUrl: string };
161
+ error: null;
162
+ } | {
163
+ data: null;
164
+ error: StorageError;
165
+ }
166
+ ```
89
167
 
90
- const { data, error } = await storageClient.from('bucket').upload('path/to/file', fileBody)
91
- ```
168
+ **示例:**
169
+ ```javascript
170
+ // 创建1小时有效的签名URL
171
+ const { data, error } = await storage.createSignedUrl('documents/report.pdf', 3600);
172
+
173
+ // 创建带图片转换的签名URL
174
+ const { data, error } = await storage.createSignedUrl('images/photo.jpg', 3600, {
175
+ transform: {
176
+ width: 300,
177
+ height: 200,
178
+ resize: 'cover',
179
+ quality: 80
180
+ }
181
+ });
182
+ ```
92
183
 
93
- > Note:
94
- > The path in `data.Key` is prefixed by the bucket ID and is not the value which should be passed to the `download` method in order to fetch the file.
95
- > To fetch the file via the `download` method, use `data.path` and `data.bucketId` as follows:
96
- >
97
- > ```javascript
98
- > const { data, error } = await storageClient.from('bucket').upload('/folder/file.txt', fileBody)
99
- > // check for errors
100
- > const { data2, error2 } = await storageClient.from(data.bucketId).download(data.path)
101
- > ```
184
+ #### `createSignedUrls(paths, expiresIn, options?)`
185
+
186
+ 批量创建签名URL。
187
+
188
+ **参数:**
189
+ - `paths` (string[]): 文件路径数组
190
+ - `expiresIn` (number): 过期时间(秒)
191
+ - `options` (object, 可选): 选项
192
+
193
+ **返回:**
194
+ ```typescript
195
+ {
196
+ data: Array<{
197
+ error: string | null;
198
+ path: string | null;
199
+ signedUrl: string;
200
+ }>;
201
+ error: null;
202
+ } | {
203
+ data: null;
204
+ error: StorageError;
205
+ }
206
+ ```
102
207
 
103
- > Note: The `upload` method also accepts a map of optional parameters. For a complete list see the [Supabase API reference](https://supabase.com/docs/reference/javascript/storage-from-upload).
208
+ ### 文件下载
104
209
 
105
- - Download a file from an exisiting bucket:
210
+ #### `download(path, options?)`
106
211
 
107
- ```js
108
- const { data, error } = await storageClient.from('bucket').download('path/to/file')
109
- ```
212
+ 从私有存储桶下载文件。
110
213
 
111
- - List all the files within a bucket:
214
+ **参数:**
215
+ - `path` (string): 文件路径
216
+ - `options` (object, 可选): 选项
217
+ - `transform` (TransformOptions): 图片转换选项
112
218
 
113
- ```js
114
- const { data, error } = await storageClient.from('bucket').list('folder')
115
- ```
219
+ **返回:**
220
+ ```typescript
221
+ {
222
+ data: Blob;
223
+ error: null;
224
+ } | {
225
+ data: null;
226
+ error: StorageError;
227
+ }
228
+ ```
116
229
 
117
- > Note: The `list` method also accepts a map of optional parameters. For a complete list see the [Supabase API reference](https://supabase.com/docs/reference/javascript/storage-from-list).
230
+ **示例:**
231
+ ```javascript
232
+ const { data, error } = await storage.download('documents/report.pdf');
233
+ if (data) {
234
+ // 处理下载的文件数据
235
+ const url = URL.createObjectURL(data);
236
+ window.open(url);
237
+ }
238
+ ```
239
+
240
+ ### 文件删除
241
+
242
+ #### `remove(paths)`
118
243
 
119
- - Replace an existing file at the specified path with a new one:
244
+ 删除指定路径的文件。
245
+
246
+ **参数:**
247
+ - `paths` (string[]): 要删除的文件路径数组
248
+
249
+ **返回:**
250
+ ```typescript
251
+ {
252
+ data: FileObject[]; // 被删除的文件信息
253
+ error: null;
254
+ } | {
255
+ data: null;
256
+ error: StorageError;
257
+ }
258
+ ```
120
259
 
121
- ```js
122
- const fileBody = ... // load your file here
260
+ **示例:**
261
+ ```javascript
262
+ const { data, error } = await storage.remove([
263
+ 'temp/file1.txt',
264
+ 'temp/file2.txt'
265
+ ]);
266
+ ```
123
267
 
124
- const { data, error } = await storageClient
125
- .from('bucket')
126
- .update('path/to/file', fileBody)
127
- ```
268
+ ### 文件列表
128
269
 
129
- > Note: The `upload` method also accepts a map of optional parameters. For a complete list see the [Supabase API reference](https://supabase.com/docs/reference/javascript/storage-from-upload).
270
+ #### `list(path?, options?, parameters?)`
130
271
 
131
- - Move an existing file:
272
+ 列出存储桶中的文件。
132
273
 
133
- ```js
134
- const { data, error } = await storageClient
135
- .from('bucket')
136
- .move('old/path/to/file', 'new/path/to/file')
137
- ```
274
+ **参数:**
275
+ - `path` (string, 可选): 文件夹路径
276
+ - `options` (SearchOptions, 可选): 搜索选项
277
+ - `parameters` (FetchParameters, 可选): 请求参数
138
278
 
139
- - Delete files within the same bucket:
279
+ **返回:**
280
+ ```typescript
281
+ {
282
+ data: FileObject[]; // 文件列表
283
+ error: null;
284
+ } | {
285
+ data: null;
286
+ error: StorageError;
287
+ }
288
+ ```
140
289
 
141
- ```js
142
- const { data, error } = await storageClient.from('bucket').remove(['path/to/file'])
143
- ```
290
+ **示例:**
291
+ ```javascript
292
+ // 列出根目录文件
293
+ const { data, error } = await storage.list();
294
+
295
+ // 搜索特定文件夹的文件
296
+ const { data, error } = await storage.list('documents', {
297
+ limit: 50,
298
+ offset: 0,
299
+ sortBy: {
300
+ column: 'name',
301
+ order: 'asc'
302
+ },
303
+ search: 'report'
304
+ });
305
+ ```
144
306
 
145
- - Create signed URL to download file without requiring permissions:
307
+ ## 类型定义
308
+
309
+ ### FileBody
310
+ 支持以下文件格式:
311
+ - `ArrayBuffer`
312
+ - `ArrayBufferView`
313
+ - `Blob`
314
+ - `Buffer`
315
+ - `File`
316
+ - `FormData`
317
+ - `NodeJS.ReadableStream`
318
+ - `ReadableStream<Uint8Array>`
319
+ - `URLSearchParams`
320
+ - `string`
321
+
322
+ ### FileOptions
323
+ ```typescript
324
+ interface FileOptions {
325
+ cacheControl?: string | number; // 缓存控制(秒)
326
+ contentType?: string; // 内容类型
327
+ upsert?: boolean; // 是否覆盖已存在文件
328
+ duplex?: string; // 双工流选项
329
+ metadata?: Record<string, any>; // 元数据
330
+ headers?: Record<string, string>; // 额外请求头
331
+ }
332
+ ```
146
333
 
147
- ```js
148
- const expireIn = 60
334
+ ### FileOptionsV2
335
+ ```typescript
336
+ interface FileOptionsV2 {
337
+ filePath?: string; // 文件路径(用于 uploadFile)
338
+ cacheControl?: string | number; // 缓存控制(秒)
339
+ contentType?: string; // 内容类型
340
+ upsert?: boolean; // 是否覆盖已存在文件
341
+ contentDisposition?: string; // 内容处置
342
+ }
343
+ ```
149
344
 
150
- const { data, error } = await storageClient
151
- .from('bucket')
152
- .createSignedUrl('path/to/file', expireIn)
153
- ```
345
+ ### TransformOptions
346
+ ```typescript
347
+ interface TransformOptions {
348
+ width?: number; // 宽度(像素)
349
+ height?: number; // 高度(像素)
350
+ resize?: 'cover' | 'contain' | 'fill'; // 调整大小模式
351
+ quality?: number; // 质量(20-100)
352
+ format?: 'origin'; // 格式
353
+ }
354
+ ```
154
355
 
155
- - Retrieve URLs for assets in public buckets:
356
+ ### UploadFileData
357
+ ```typescript
358
+ interface UploadFileData {
359
+ id: string; // 文件ID
360
+ file_path: string; // 文件路径
361
+ bucket_id: string; // 存储桶ID
362
+ download_url: string; // 下载URL
363
+ }
364
+ ```
365
+
366
+ ### FileObject
367
+ ```typescript
368
+ interface FileObject {
369
+ name: string; // 文件名
370
+ bucket_id: string; // 存储桶ID
371
+ owner: string; // 所有者
372
+ id: string; // 文件ID
373
+ updated_at: string; // 更新时间
374
+ created_at: string; // 创建时间
375
+ created_by: string; // 创建者
376
+ updated_by: string; // 更新者
377
+ last_accessed_at?: string; // 最后访问时间
378
+ metadata: Record<string, any>; // 元数据
379
+ buckets: Bucket; // 存储桶信息
380
+ }
381
+ ```
382
+
383
+ ### SearchOptions
384
+ ```typescript
385
+ interface SearchOptions {
386
+ limit?: number; // 返回文件数量(默认100)
387
+ offset?: number; // 起始位置
388
+ sortBy?: SortBy; // 排序选项
389
+ search?: string; // 搜索字符串
390
+ }
391
+ ```
392
+
393
+ ### FetchParameters
394
+ ```typescript
395
+ interface FetchParameters {
396
+ signal?: AbortSignal; // AbortController 信号
397
+ }
398
+ ```
399
+
400
+ ## 错误处理
401
+
402
+ 所有API方法都返回包含 `data` 和 `error` 的对象。当操作成功时,`error` 为 `null`,`data` 包含返回数据;当操作失败时,`data` 为 `null`,`error` 包含错误信息。
403
+
404
+ ```javascript
405
+ const { data, error } = await storage.upload('test.jpg', file);
406
+
407
+ if (error) {
408
+ console.error('操作失败:', error.message);
409
+ // 错误处理
410
+ } else {
411
+ console.log('操作成功:', data);
412
+ // 处理返回数据
413
+ }
414
+ ```
415
+
416
+ ## 高级用法
417
+
418
+ ### 日志记录
419
+
420
+ 可以通过设置 `loggerEnabled` 参数启用请求日志记录:
421
+
422
+ ```javascript
423
+ const storage = new StorageFileApi(
424
+ 'https://your-storage-service.com',
425
+ { 'Authorization': 'Bearer your-token' },
426
+ 'bucket-id',
427
+ 'app-id',
428
+ undefined,
429
+ true // 启用日志
430
+ );
431
+ ```
432
+
433
+ ### 错误回调
434
+
435
+ 可以设置请求错误回调函数:
436
+
437
+ ```javascript
438
+ const storage = new StorageFileApi(
439
+ 'https://your-storage-service.com',
440
+ { 'Authorization': 'Bearer your-token' },
441
+ 'bucket-id',
442
+ 'app-id',
443
+ undefined,
444
+ false,
445
+ (error) => {
446
+ console.error('请求错误:', error);
447
+ // 自定义错误处理
448
+ }
449
+ );
450
+ ```
451
+
452
+ ### 自定义 fetch
453
+
454
+ 可以传入自定义的 fetch 函数:
455
+
456
+ ```javascript
457
+ const customFetch = (url, options) => {
458
+ // 自定义 fetch 逻辑
459
+ return fetch(url, options);
460
+ };
461
+
462
+ const storage = new StorageFileApi(
463
+ 'https://your-storage-service.com',
464
+ { 'Authorization': 'Bearer your-token' },
465
+ 'bucket-id',
466
+ 'app-id',
467
+ customFetch
468
+ );
469
+ ```
156
470
 
157
- ```js
158
- const { data, error } = await storageClient.from('public-bucket').getPublicUrl('path/to/file')
159
- ```
471
+ ## 许可证
160
472
 
161
- ## Sponsors
473
+ MIT License
162
474
 
163
- We are building the features of Firebase using enterprise-grade, open source products. We support existing communities wherever possible, and if the products don’t exist we build them and open source them ourselves. Thanks to these sponsors who are making the OSS ecosystem better for everyone.
475
+ ## 相关链接
164
476
 
165
- [![New Sponsor](https://user-images.githubusercontent.com/10214025/90518111-e74bbb00-e198-11ea-8f88-c9e3c1aa4b5b.png)](https://github.com/sponsors/supabase)
477
+ - [Dataloom 官网](https://dataloom.com)
478
+ - [GitHub 仓库](https://github.com/your-org/dataloom-sdk)
479
+ - [问题反馈](https://github.com/your-org/dataloom-sdk/issues)
@@ -4,7 +4,7 @@ import { Fetch } from './lib/fetch';
4
4
  import { type OnRequestErrorType } from './lib/types';
5
5
  export interface StorageClientOptions {
6
6
  useNewHostname?: boolean;
7
- logger?: boolean;
7
+ enableLogger?: boolean;
8
8
  appId?: string;
9
9
  onRequestError: (error: OnRequestErrorType) => void;
10
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"StorageClient.d.ts","sourceRoot":"","sources":["../../src/StorageClient.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,2BAA2B,CAAC;AACvD,OAAO,gBAAgB,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;CACrD;AAED,qBAAa,aAAc,SAAQ,gBAAgB;gBAE/C,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAO,EACvC,KAAK,CAAC,EAAE,KAAK,EACb,IAAI,CAAC,EAAE,oBAAoB;IAK7B;;;;OAIG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc;CAWjC"}
1
+ {"version":3,"file":"StorageClient.d.ts","sourceRoot":"","sources":["../../src/StorageClient.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,2BAA2B,CAAC;AACvD,OAAO,gBAAgB,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;CACrD;AAED,qBAAa,aAAc,SAAQ,gBAAgB;gBAE/C,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAO,EACvC,KAAK,CAAC,EAAE,KAAK,EACb,IAAI,CAAC,EAAE,oBAAoB;IAK7B;;;;OAIG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc;CAWjC"}
@@ -94,9 +94,35 @@ export interface FileOptions {
94
94
  */
95
95
  headers?: Record<string, string>;
96
96
  }
97
+ export interface FileOptionsV2 {
98
+ /**
99
+ *
100
+ */
101
+ filePath?: string;
102
+ /**
103
+ * The number of seconds the asset is cached in the browser and in the Supabase CDN. This is set in the `Cache-Control: max-age=<seconds>` header.
104
+ */
105
+ cacheControl?: string | number;
106
+ /**
107
+ * the `Content-Type` header value.
108
+ */
109
+ contentType?: string;
110
+ /**
111
+ * When upsert is set to true, the file is overwritten if it exists. When set to false, an error is thrown if the object already exists. Defaults to false.
112
+ */
113
+ upsert?: boolean;
114
+ /**
115
+ * The `Content-Disposition` resposne header value when downloading the file.
116
+ */
117
+ contentDisposition?: string;
118
+ }
97
119
  export interface PreUploadBody {
120
+ bucket_id: string;
98
121
  file_size: string;
99
- upsert: boolean;
122
+ upsert?: boolean;
123
+ file_path?: string;
124
+ content_disposition?: string;
125
+ content_type?: string;
100
126
  }
101
127
  export interface DestinationOptions {
102
128
  destinationBucket?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/types.ts"],"names":[],"mappings":";;;AAAA,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,GAAG;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,WAAW,CAAC;AAElD,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAA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"}
@@ -12,7 +12,7 @@ class StorageBucketApi {
12
12
  this.fetch = (0, helpers_1.resolveFetch)(fetch);
13
13
  this.onRequestError = opts === null || opts === void 0 ? void 0 : opts.onRequestError;
14
14
  this.appId = opts === null || opts === void 0 ? void 0 : opts.appId;
15
- if (opts === null || opts === void 0 ? void 0 : opts.logger) {
15
+ if (opts === null || opts === void 0 ? void 0 : opts.enableLogger) {
16
16
  this.loggerEnabled = true;
17
17
  }
18
18
  }