Skip to content

Commit 1b81947

Browse files
author
winddies
authored
修复单位比较错误的问题 (#453)
* fix review * import MB unit
1 parent 0d1d24e commit 1b81947

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "qiniu-js",
33
"jsName": "qiniu",
4-
"version": "3.0.1",
4+
"version": "3.0.2",
55
"private": false,
66
"description": "Javascript SDK for Qiniu Resource (Cloud) Storage AP",
77
"main": "lib/index.js",

src/upload/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import Resume from './resume'
22
import Direct from './direct'
3-
import { UploadOptions, UploadHandler, DEFAULT_CHUNK_SIZE } from './base'
3+
import { UploadOptions, UploadHandler } from './base'
44
import StatisticsLogger from '../statisticsLog'
5+
import { MB } from '../utils'
56

67
export * from './base'
78
export * from './resume'
@@ -15,7 +16,7 @@ export default function createUploadManager(
1516
return new Direct(options, handlers, statisticsLogger)
1617
}
1718

18-
return options.file.size > DEFAULT_CHUNK_SIZE
19+
return options.file.size > 4 * MB
1920
? new Resume(options, handlers, statisticsLogger)
2021
: new Direct(options, handlers, statisticsLogger)
2122
}

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import SparkMD5 from 'spark-md5'
22
import { Progress, LocalInfo } from './upload'
33
import { urlSafeBase64Decode } from './base64'
44

5-
const MB = 1024 ** 2
5+
export const MB = 1024 ** 2
66

77
// 文件分块
88
export function getChunks(file: File, blockSize: number): Blob[] {

0 commit comments

Comments
 (0)