File tree Expand file tree Collapse file tree 4 files changed +21
-12
lines changed Expand file tree Collapse file tree 4 files changed +21
-12
lines changed 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.3 " ,
4
+ "version" : " 2.5.4 " ,
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,24 +5,23 @@ export class StatisticsLogger{
5
5
log ( info , token ) {
6
6
let logString = "" ;
7
7
Object . keys ( info ) . forEach ( k => logString += info [ k ] + "," ) ;
8
- this . send ( logString , token ) ;
8
+ this . send ( logString , token , 0 ) ;
9
9
}
10
10
11
- send ( logString , token ) {
11
+ send ( logString , token , retryCount ) {
12
12
let xhr = createXHR ( ) ;
13
- let count = 0 ;
13
+ let self = this ;
14
14
xhr . open ( "POST" , "https://uplog.qbox.me/log/3" ) ;
15
15
xhr . setRequestHeader ( "Content-type" , "application/x-www-form-urlencoded" ) ;
16
16
xhr . setRequestHeader ( "Authorization" , "UpToken " + token ) ;
17
17
xhr . onreadystatechange = function ( ) {
18
18
if ( xhr . readyState === 4 ) {
19
19
if ( xhr . status !== 200 ) {
20
- count ++ ;
21
- count <= 3 ? xhr . send ( logString ) : "" ;
22
- }
20
+ ++ retryCount <= 3 && self . send ( logString , token , retryCount ) ;
21
+ }
23
22
}
24
23
} ;
25
24
xhr . send ( logString ) ;
26
25
}
27
26
28
- }
27
+ }
Original file line number Diff line number Diff line change @@ -188,7 +188,6 @@ export class UploadManager {
188
188
removeLocalFileInfo ( this . file ) ;
189
189
return ;
190
190
}
191
- setLocalFileInfo ( this . file , this . ctxList ) ;
192
191
}
193
192
) ;
194
193
return result ;
@@ -231,12 +230,16 @@ export class UploadManager {
231
230
onProgress,
232
231
onCreate
233
232
} ) . then ( response => {
233
+ // 在某些浏览器环境下,xhr 的 progress 事件无法被触发,progress 为 null,这里在每次分片上传完成后都手动更新下 progress
234
+ onProgress ( { loaded : chunk . size } ) ;
235
+
234
236
this . ctxList [ index ] = {
235
237
time : new Date ( ) . getTime ( ) ,
236
238
ctx : response . data . ctx ,
237
239
size : chunk . size ,
238
240
md5 : md5
239
241
} ;
242
+ setLocalFileInfo ( this . file , this . ctxList ) ;
240
243
} ) ;
241
244
} ) ;
242
245
}
@@ -272,9 +275,16 @@ export class UploadManager {
272
275
this . onData ( this . progress ) ;
273
276
}
274
277
275
- finishDirectProgress ( ) {
278
+ finishDirectProgress ( ) {
279
+ // 在某些浏览器环境下,xhr 的 progress 事件无法被触发,progress 为 null, 这里 fake 下
280
+ if ( ! this . progress ) {
281
+ this . progress = { total : this . getProgressInfoItem ( this . file . size , this . file . size ) } ;
282
+ this . onData ( this . progress ) ;
283
+ return ;
284
+ }
285
+
276
286
let total = this . progress . total ;
277
- this . progress . total = this . getProgressInfoItem ( total . loaded + 1 , total . size ) ;
287
+ this . progress = { total : this . getProgressInfoItem ( total . loaded + 1 , total . size ) } ;
278
288
this . onData ( this . progress ) ;
279
289
}
280
290
Original file line number Diff line number Diff line change 15
15
"babel-polyfill" : " ^6.26.0" ,
16
16
"babel-preset-env" : " ^1.6.0" ,
17
17
"babel-runtime" : " ^6.26.0" ,
18
- "qiniu-js" :" ^2.0.2" ,
19
18
"es3ify-loader" : " ^0.2.0" ,
20
19
"open-browser-webpack-plugin" : " 0.0.5" ,
20
+ "qiniu-js" : " ^2.5.4" ,
21
21
"uglifyjs-webpack-plugin" : " ^1.1.6" ,
22
22
"webpack" : " ^3.6.0" ,
23
23
"webpack-dev-server" : " ^2.9.1"
You can’t perform that action at this time.
0 commit comments