@data-loom/storage-js 0.4.2-alpha.2 → 0.4.2
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 +23 -29
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -79,6 +79,26 @@ constructor(
|
|
|
79
79
|
|
|
80
80
|
### 文件上传
|
|
81
81
|
|
|
82
|
+
#### `uploadFile(fileBody, fileOptions?)` **(推荐)**
|
|
83
|
+
|
|
84
|
+
使用文件选项上传文件(推荐, 无需关注filePath)。
|
|
85
|
+
|
|
86
|
+
**参数:**
|
|
87
|
+
- `fileBody` (FileBody): 文件内容
|
|
88
|
+
- `fileOptions` (FileOptionsV2, 可选): 文件选项,可指定 filePath 等
|
|
89
|
+
|
|
90
|
+
**返回:** 同 `upload` 方法
|
|
91
|
+
|
|
92
|
+
**示例:**
|
|
93
|
+
```javascript
|
|
94
|
+
const { data, error } = await storage.uploadFile(file, {
|
|
95
|
+
filePath: 'documents/report.pdf',
|
|
96
|
+
cacheControl: 3600,
|
|
97
|
+
contentType: 'application/pdf',
|
|
98
|
+
contentDisposition: 'attachment; filename="report.pdf"'
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
82
102
|
#### `upload(path, fileBody, fileOptions?)`
|
|
83
103
|
|
|
84
104
|
上传文件到指定的存储桶路径。
|
|
@@ -111,26 +131,6 @@ const { data, error } = await storage.upload('avatars/user-123.jpg', file, {
|
|
|
111
131
|
});
|
|
112
132
|
```
|
|
113
133
|
|
|
114
|
-
#### `uploadFile(fileBody, fileOptions?)`
|
|
115
|
-
|
|
116
|
-
使用文件选项上传文件(推荐, 无需关注filePath)。
|
|
117
|
-
|
|
118
|
-
**参数:**
|
|
119
|
-
- `fileBody` (FileBody): 文件内容
|
|
120
|
-
- `fileOptions` (FileOptionsV2, 可选): 文件选项,可指定 filePath 等
|
|
121
|
-
|
|
122
|
-
**返回:** 同 `upload` 方法
|
|
123
|
-
|
|
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
|
-
```
|
|
133
|
-
|
|
134
134
|
### 文件更新
|
|
135
135
|
|
|
136
136
|
#### `update(path, fileBody, fileOptions?)`
|
|
@@ -148,7 +148,7 @@ const { data, error } = await storage.uploadFile(file, {
|
|
|
148
148
|
创建具有时效性的安全文件访问链接。
|
|
149
149
|
|
|
150
150
|
**参数:**
|
|
151
|
-
- `path` (string):
|
|
151
|
+
- `path` (string): 文件路径或上传接口返回的download_url
|
|
152
152
|
- `expiresIn` (number): 过期时间(秒)
|
|
153
153
|
- `options` (object, 可选): 选项
|
|
154
154
|
- `download` (string | boolean): 是否触发下载,可指定文件名
|
|
@@ -186,7 +186,7 @@ const { data, error } = await storage.createSignedUrl('images/photo.jpg', 3600,
|
|
|
186
186
|
批量创建签名URL。
|
|
187
187
|
|
|
188
188
|
**参数:**
|
|
189
|
-
- `paths` (string[]):
|
|
189
|
+
- `paths` (string[]): 文件路径或上传接口返回的download_url数组
|
|
190
190
|
- `expiresIn` (number): 过期时间(秒)
|
|
191
191
|
- `options` (object, 可选): 选项
|
|
192
192
|
|
|
@@ -244,7 +244,7 @@ if (data) {
|
|
|
244
244
|
删除指定路径的文件。
|
|
245
245
|
|
|
246
246
|
**参数:**
|
|
247
|
-
- `paths` (string[]):
|
|
247
|
+
- `paths` (string[]): 要删除的文件路径或上传接口返回的download_url数组
|
|
248
248
|
|
|
249
249
|
**返回:**
|
|
250
250
|
```typescript
|
|
@@ -471,9 +471,3 @@ const storage = new StorageFileApi(
|
|
|
471
471
|
## 许可证
|
|
472
472
|
|
|
473
473
|
MIT License
|
|
474
|
-
|
|
475
|
-
## 相关链接
|
|
476
|
-
|
|
477
|
-
- [Dataloom 官网](https://dataloom.com)
|
|
478
|
-
- [GitHub 仓库](https://github.com/your-org/dataloom-sdk)
|
|
479
|
-
- [问题反馈](https://github.com/your-org/dataloom-sdk/issues)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@data-loom/storage-js",
|
|
3
|
-
"version": "0.4.2
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Dataloom service, modified from supabase/storage-js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"service",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"test:types:watch": "run-s build && tsd --files 'test/**/*.test-d.ts' --watch"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@data-loom/node-fetch": "0.4.2
|
|
36
|
+
"@data-loom/node-fetch": "0.4.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/jest": "^26.0.13",
|