File tree Expand file tree Collapse file tree 4 files changed +15
-25
lines changed Expand file tree Collapse file tree 4 files changed +15
-25
lines changed Original file line number Diff line number Diff line change @@ -185,7 +185,7 @@ qiniu.compressImage(file, options).then(data => {
185
185
* config .disableStatisticsReport : 是否禁用日志报告,为布尔值,默认为 ` false` 。
186
186
* config .uphost : 上传 ` host` ,类型为 ` string` , 如果设定该参数则优先使用该参数作为上传地址,默认为 ` null` 。
187
187
* config .region : 选择上传域名区域;当为 ` null` 或 ` undefined` 时,自动分析上传域名区域。
188
- * config .retryCount : 上传自动重试次数(整体重试次数,而不是某个分片的重试次数);默认 3 次(即上传失败后最多重试两次); ** 目前仅在上传过程中产生 ` 599 ` 内部错误时生效 ** , ** 但是未来很可能会扩展为支持更多的情况 ** 。
188
+ * config .retryCount : 上传自动重试次数(整体重试次数,而不是某个分片的重试次数);默认 3 次(即上传失败后最多重试两次)。
189
189
* config .concurrentRequestLimit : 分片上传的并发请求量,` number` ,默认为3 ;因为浏览器本身也会限制最大并发量,所以最大并发量与浏览器有关。
190
190
* config .checkByMD5 : 是否开启 MD5 校验,为布尔值;在断点续传时,开启 MD5 校验会将已上传的分片与当前分片进行 MD5 值比对,若不一致,则重传该分片,避免使用错误的分片。读取分片内容并计算 MD5 需要花费一定的时间,因此会稍微增加断点续传时的耗时,默认为 false ,不开启。
191
191
* config .forceDirect : 是否上传全部采用直传方式,为布尔值;为 ` true` 时则上传方式全部为直传 form 方式,禁用断点续传,默认 ` false` 。
@@ -201,7 +201,7 @@ qiniu.compressImage(file, options).then(data => {
201
201
` ` `
202
202
203
203
* fname: ` string` ,文件原文件名
204
- * params: ` object` ,用来放置自定义变量
204
+ * params: ` object` ,用来放置自定义变量,自定义变量格式请参考[文档](https : // developer.qiniu.com/kodo/manual/1235/vars)
205
205
* mimeType: ` null || array` ,用来限制上传文件类型,为 ` null` 时表示不对文件类型限制;限制类型放到数组里:
206
206
` ["image/png", "image/jpeg", "image/gif"]`
207
207
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " qiniu-js" ,
3
3
"jsName" : " qiniu" ,
4
- "version" : " 2.5.4 " ,
4
+ "version" : " 2.5.5 " ,
5
5
"private" : false ,
6
6
"description" : " Javascript SDK for Qiniu Resource (Cloud) Storage AP" ,
7
7
"main" : " dist/qiniu.min.js" ,
Original file line number Diff line number Diff line change 5
5
setLocalFileInfo ,
6
6
removeLocalFileInfo ,
7
7
getLocalFileInfo ,
8
- findMimeType ,
8
+ isContainFileMimeType ,
9
9
sum ,
10
10
getDomainFromUrl ,
11
11
getPortFromUrl ,
@@ -64,15 +64,11 @@ export class UploadManager {
64
64
if ( ! this . putExtra . fname ) {
65
65
this . putExtra . fname = this . file . name ;
66
66
}
67
- if ( this . putExtra . mimeType && this . putExtra . mimeType . length ) {
68
- var compareMimeType = findMimeType ( this . file . type , this . putExtra . mimeType ) ;
69
- if ( compareMimeType == null || compareMimeType == undefined ) {
70
- let err = new Error ( "file type doesn't match with what you specify" ) ;
71
- this . onError ( err ) ;
72
- return ;
73
- } else {
74
- this . putExtra . mimeType = [ compareMimeType ] ;
75
- }
67
+ if ( this . putExtra . mimeType && this . putExtra . mimeType . length
68
+ && ! isContainFileMimeType ( this . file . type , this . putExtra . mimeType ) ) {
69
+ let err = new Error ( "file type doesn't match with what you specify" ) ;
70
+ this . onError ( err ) ;
71
+ return ;
76
72
}
77
73
let upload = getUploadUrl ( this . config , this . token ) . then ( res => {
78
74
this . uploadUrl = res ;
@@ -255,7 +251,7 @@ export class UploadManager {
255
251
256
252
let requestUrL = createMkFileUrl (
257
253
this . uploadUrl ,
258
- this . file . size ,
254
+ this . file ,
259
255
this . key ,
260
256
putExtra
261
257
) ;
Original file line number Diff line number Diff line change @@ -80,13 +80,13 @@ export function getResumeUploadedSize(file) {
80
80
}
81
81
82
82
// 构造file上传url
83
- export function createMkFileUrl ( url , size , key , putExtra ) {
84
- let requestUrl = url + "/mkfile/" + size ;
83
+ export function createMkFileUrl ( url , file , key , putExtra ) {
84
+ let requestUrl = url + "/mkfile/" + file . size ;
85
85
if ( key != null ) {
86
86
requestUrl += "/key/" + urlSafeBase64Encode ( key ) ;
87
87
}
88
88
if ( putExtra . mimeType ) {
89
- requestUrl += "/mimeType/" + urlSafeBase64Encode ( putExtra . mimeType ) ;
89
+ requestUrl += "/mimeType/" + urlSafeBase64Encode ( file . type ) ;
90
90
}
91
91
let fname = putExtra . fname ;
92
92
if ( fname ) {
@@ -264,14 +264,8 @@ function getUpHosts(token) {
264
264
}
265
265
}
266
266
267
- export function findMimeType ( fileType , mimeType ) {
268
- var rtType = null ;
269
- mimeType . forEach ( elem => {
270
- if ( fileType == elem ) {
271
- rtType = fileType ;
272
- }
273
- } ) ;
274
- return rtType ;
267
+ export function isContainFileMimeType ( fileType , mimeType ) {
268
+ return mimeType . indexOf ( fileType ) > - 1 ;
275
269
}
276
270
277
271
export function createObjectURL ( file ) {
You can’t perform that action at this time.
0 commit comments