-
Notifications
You must be signed in to change notification settings - Fork 3
/
presets.js
68 lines (64 loc) · 2.17 KB
/
presets.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
export const RETRY_MAX = 3
export const CONFIG_ID = 23 // OSS ID
export const MB = 1024 ** 2
export const TEN_MB = 10 * MB
export const GB = MB * 1024
export const TEN_GB = 10 * GB
// 文件存储S3协议的限制,分片数量不能超过1000个
export function getChunkSize(fileSize) {
return fileSize > TEN_GB ? fileSize / 1000 : TEN_MB
}
// 任意类型文件的配置预设
const common = {
maxFiles: 5,
}
// 不同类型文件的配置预设 (优先级更高)
const catalog = {
image: {
maxFiles: 5,
// imageValidateSizeMaxWidth: 5000,
// imageValidateSizeMaxHeight: 5000,
imageAspectRatio: '1:1',
acceptedFileTypes: ['image/jpeg', 'image/png'],
labelIdle: '将图片拖到此处,或点击上传',
},
audio: {
maxFiles: 1,
// minFileSize: '1MB',
acceptedFileTypes: ['audio/*'],
audioDuration: { max: 22 },
labelIdle: '将音频拖到此处,或点击上传',
fileValidateTypeLabelExpectedTypes: '应为 {allTypes}',
},
video: {
maxFiles: 2,
maxFileSize: '100MB',
acceptedFileTypes: ['video/*'],
// videoWidth: { max: 1280 },
// videoHeight: 720,
videoAspectRatio: { min: '16:10', max: '16:9' },
videoResolution: 1280 * 720,
videoDuration: { max: 14 },
labelIdle: '将视频拖到此处,或点击上传',
fileValidateTypeLabelExpectedTypes: '应为 {allTypes}',
},
pdf: {
acceptedFileTypes: ['application/pdf'],
labelIdle: '将 PDF 文件拖到此处,或点击上传',
fileValidateTypeLabelExpectedTypes: '应为 {allTypes}',
},
excel: {
// acceptedFileTypes: ['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.ms-excel'],
acceptedFileTypes: ['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', '.xls'],
labelIdle: '将 Excel 文件拖到此处,或点击上传',
},
apk: {
acceptedFileTypes: ['application/vnd.android.package-archive'],
labelIdle: '将 APK 文件拖到此处,或点击上传',
fileValidateTypeLabelExpectedTypes: '应为 {allTypes}',
},
}
export default Object.fromEntries(Array.from(
Object.keys(catalog),
fileType => [fileType, { ...common, ...catalog[fileType] }],
))