@kmlckj/licos-platform-sdk 0.4.0 → 0.5.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 +4 -2
- package/package.json +1 -1
- package/src/browser.js +1 -0
- package/src/index.js +1 -0
- package/src/shared.js +1 -1
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ LICOS 平台对象存储 SDK,兼容前端和后端调用。
|
|
|
9
9
|
- 这些存储接口实际挂在调度器 `/api/v1/storage/*` 和 `/api/v1/public/storage/*`
|
|
10
10
|
- `uploadUser` / `uploadProject` 支持直接传本地文件路径
|
|
11
11
|
- `download(url, outputPath)` 会把文件写到本地路径
|
|
12
|
+
- 上传、预览、下载都要求鉴权;`download(...)` 会自动带上 `token` 或 `LICOS_USER_TOKEN`
|
|
12
13
|
|
|
13
14
|
```js
|
|
14
15
|
import { uploadProject, download } from '@kmlckj/licos-platform-sdk';
|
|
@@ -23,6 +24,7 @@ await download(uploaded.download_url, '/tmp/report-downloaded.pdf');
|
|
|
23
24
|
- 上传支持 `File` / `Blob` / `ArrayBuffer` / TypedArray / `{ data, fileName, contentType }`
|
|
24
25
|
- `download(url)` 返回 `Blob`
|
|
25
26
|
- TypeScript 前端可显式导入浏览器入口 `@kmlckj/licos-platform-sdk/browser`,拿到浏览器专用类型
|
|
27
|
+
- 预览 / 下载接口同样要求传 `token`
|
|
26
28
|
|
|
27
29
|
```js
|
|
28
30
|
import { uploadUser, download } from '@kmlckj/licos-platform-sdk';
|
|
@@ -31,7 +33,7 @@ const uploaded = await uploadUser(fileInput.files[0], {
|
|
|
31
33
|
token: userJwt,
|
|
32
34
|
});
|
|
33
35
|
|
|
34
|
-
const blob = await download(uploaded.download_url);
|
|
36
|
+
const blob = await download(uploaded.download_url, { token: userJwt });
|
|
35
37
|
```
|
|
36
38
|
|
|
37
39
|
```ts
|
|
@@ -41,5 +43,5 @@ const uploaded = await uploadUser(fileInput.files![0], {
|
|
|
41
43
|
token: userJwt,
|
|
42
44
|
});
|
|
43
45
|
|
|
44
|
-
const blob = await download(uploaded.download_url);
|
|
46
|
+
const blob = await download(uploaded.download_url, { token: userJwt });
|
|
45
47
|
```
|
package/package.json
CHANGED
package/src/browser.js
CHANGED
package/src/index.js
CHANGED
package/src/shared.js
CHANGED
|
@@ -225,7 +225,7 @@ export async function downloadBlob(fetchImpl, url, options = {}) {
|
|
|
225
225
|
url,
|
|
226
226
|
buildRequestInit(options, {
|
|
227
227
|
method: 'GET',
|
|
228
|
-
headers: buildRequestHeaders(options),
|
|
228
|
+
headers: buildRequestHeaders(options, { authenticated: true }),
|
|
229
229
|
}),
|
|
230
230
|
);
|
|
231
231
|
if (!response.ok) {
|