tt-uploader 1.5.2 → 1.5.4-beta.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 +82 -0
- package/package.json +1 -1
- package/types/index.d.ts +4 -0
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# tt-uploader
|
|
2
|
+
|
|
3
|
+
上传组件,支持火山引擎 veVod(视频点播)和 veImageX(图片服务)的文件上传功能。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- 支持视频和图片文件上传
|
|
8
|
+
- 支持分片上传和直传两种模式
|
|
9
|
+
- 支持断点续传
|
|
10
|
+
- 支持上传进度监听
|
|
11
|
+
- 支持暂停、恢复、取消上传
|
|
12
|
+
- 支持本地缓存(localStorage)
|
|
13
|
+
- 支持自定义配置和插件扩展
|
|
14
|
+
|
|
15
|
+
## 安装
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm i tt-uploader
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 使用示例
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
import TTUploader from 'tt-uploader'
|
|
25
|
+
|
|
26
|
+
const uploader = new TTUploader({
|
|
27
|
+
stsToken: {
|
|
28
|
+
// your sts token
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
// 添加文件
|
|
33
|
+
const key = uploader.addFile({
|
|
34
|
+
file: fileObject,
|
|
35
|
+
// other options
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
// 监听上传进度
|
|
39
|
+
uploader.on('progress', (info) => {
|
|
40
|
+
console.log('上传进度:', info.percent)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
// 监听上传完成
|
|
44
|
+
uploader.on('complete', (info) => {
|
|
45
|
+
console.log('上传成功:', info)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
// 监听上传错误
|
|
49
|
+
uploader.on('error', (info) => {
|
|
50
|
+
console.log('上传失败:', info)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
// 开始上传
|
|
54
|
+
uploader.start(key)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 文档
|
|
58
|
+
|
|
59
|
+
- veVod: https://www.volcengine.com/docs/4/66560
|
|
60
|
+
- veImageX: https://www.volcengine.com/docs/508/66132
|
|
61
|
+
|
|
62
|
+
## 更新日志
|
|
63
|
+
|
|
64
|
+
### 1.5.4
|
|
65
|
+
|
|
66
|
+
- 支持 localStorage 和 enableDebugLog 打印日志
|
|
67
|
+
- 新增 `enableDebugLog` 配置项,支持通过配置或 localStorage 控制调试日志输出
|
|
68
|
+
- 支持通过 localStorage 设置调试日志开关
|
|
69
|
+
|
|
70
|
+
- 添加 `useFileNameInCacheKey` 选项,增强缓存功能
|
|
71
|
+
- 支持使用文件名作为缓存 key 的一部分,提升缓存准确性
|
|
72
|
+
|
|
73
|
+
- 支持自定义 TOP 请求
|
|
74
|
+
- 优化 apply 和 commit 阶段的请求处理逻辑
|
|
75
|
+
|
|
76
|
+
- 确保容灾请求会带上对应的 gateway header
|
|
77
|
+
- 修复容灾切换时 header 丢失导致失败请求成功的问题
|
|
78
|
+
|
|
79
|
+
- 优化错误处理逻辑
|
|
80
|
+
- 当遇到错误码 4024(InMergedError)和 4025(AlreadyExistedError)时,自动清空本地缓存,避免使用过期缓存导致一直失败
|
|
81
|
+
- 优化重试和错误日志打印逻辑
|
|
82
|
+
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -56,6 +56,8 @@ export interface InitConfig {
|
|
|
56
56
|
getSliceFunc?: (fileSize: number) => number
|
|
57
57
|
uploadTimeout?: number
|
|
58
58
|
requestTimeout?: number
|
|
59
|
+
useConsoleMode?: boolean
|
|
60
|
+
useFileNameInCacheKey?: boolean
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
export interface UpdateOptions {
|
|
@@ -65,6 +67,8 @@ export interface UpdateOptions {
|
|
|
65
67
|
imageConfig?: ImageConfig
|
|
66
68
|
useFileExtension?: boolean
|
|
67
69
|
useLocalStorage?: boolean
|
|
70
|
+
useConsoleMode?: boolean
|
|
71
|
+
useFileNameInCacheKey?: boolean
|
|
68
72
|
}
|
|
69
73
|
export interface VodFileOption {
|
|
70
74
|
file: Blob
|