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 11{
22 "name" : " qiniu-js" ,
33 "jsName" : " qiniu" ,
4- "version" : " 2.5.3 " ,
4+ "version" : " 2.5.4 " ,
55 "private" : false ,
66 "description" : " Javascript SDK for Qiniu Resource (Cloud) Storage AP" ,
77 "main" : " dist/qiniu.min.js" ,
Original file line number Diff line number Diff line change @@ -5,24 +5,23 @@ export class StatisticsLogger{
55 log ( info , token ) {
66 let logString = "" ;
77 Object . keys ( info ) . forEach ( k => logString += info [ k ] + "," ) ;
8- this . send ( logString , token ) ;
8+ this . send ( logString , token , 0 ) ;
99 }
1010
11- send ( logString , token ) {
11+ send ( logString , token , retryCount ) {
1212 let xhr = createXHR ( ) ;
13- let count = 0 ;
13+ let self = this ;
1414 xhr . open ( "POST" , "https://uplog.qbox.me/log/3" ) ;
1515 xhr . setRequestHeader ( "Content-type" , "application/x-www-form-urlencoded" ) ;
1616 xhr . setRequestHeader ( "Authorization" , "UpToken " + token ) ;
1717 xhr . onreadystatechange = function ( ) {
1818 if ( xhr . readyState === 4 ) {
1919 if ( xhr . status !== 200 ) {
20- count ++ ;
21- count <= 3 ? xhr . send ( logString ) : "" ;
22- }
20+ ++ retryCount <= 3 && self . send ( logString , token , retryCount ) ;
21+ }
2322 }
2423 } ;
2524 xhr . send ( logString ) ;
2625 }
2726
28- }
27+ }
Original file line number Diff line number Diff line change @@ -188,7 +188,6 @@ export class UploadManager {
188188 removeLocalFileInfo ( this . file ) ;
189189 return ;
190190 }
191- setLocalFileInfo ( this . file , this . ctxList ) ;
192191 }
193192 ) ;
194193 return result ;
@@ -231,12 +230,16 @@ export class UploadManager {
231230 onProgress,
232231 onCreate
233232 } ) . then ( response => {
233+ // 在某些浏览器环境下,xhr 的 progress 事件无法被触发,progress 为 null,这里在每次分片上传完成后都手动更新下 progress
234+ onProgress ( { loaded : chunk . size } ) ;
235+
234236 this . ctxList [ index ] = {
235237 time : new Date ( ) . getTime ( ) ,
236238 ctx : response . data . ctx ,
237239 size : chunk . size ,
238240 md5 : md5
239241 } ;
242+ setLocalFileInfo ( this . file , this . ctxList ) ;
240243 } ) ;
241244 } ) ;
242245 }
@@ -272,9 +275,16 @@ export class UploadManager {
272275 this . onData ( this . progress ) ;
273276 }
274277
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+
276286 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 ) } ;
278288 this . onData ( this . progress ) ;
279289 }
280290
Original file line number Diff line number Diff line change 1515 "babel-polyfill" : " ^6.26.0" ,
1616 "babel-preset-env" : " ^1.6.0" ,
1717 "babel-runtime" : " ^6.26.0" ,
18- "qiniu-js" :" ^2.0.2" ,
1918 "es3ify-loader" : " ^0.2.0" ,
2019 "open-browser-webpack-plugin" : " 0.0.5" ,
20+ "qiniu-js" : " ^2.5.4" ,
2121 "uglifyjs-webpack-plugin" : " ^1.1.6" ,
2222 "webpack" : " ^3.6.0" ,
2323 "webpack-dev-server" : " ^2.9.1"
You can’t perform that action at this time.
0 commit comments