6
6
*
7
7
* GitHub: http://github.com/qiniu/js-sdk
8
8
*
9
- * Date: 2016-9-12
9
+ * Date: 2016-9-30
10
10
*/
11
11
12
12
/*global plupload ,mOxie*/
@@ -599,22 +599,52 @@ function QiniuJsSDK() {
599
599
var segments = uptoken . split ( ":" ) ;
600
600
var ak = segments [ 0 ] ;
601
601
var putPolicy = that . parseJSON ( that . URLSafeBase64Decode ( segments [ 2 ] ) ) ;
602
- var uphosts_url = "https://uc.qbox.me/v1/query?ak=" + ak + "&bucket=" + putPolicy . scope ;
602
+ // var uphosts_url = "//uc.qbox.me/v1/query?ak="+ak+"&bucket="+putPolicy.scope;
603
+ // IE 9- is not support protocal relative url
604
+ var uphosts_url = window . location . protocol + "//uc.qbox.me/v1/query?ak=" + ak + "&bucket=" + putPolicy . scope ;
603
605
logger . debug ( "ak: " , ak ) ;
604
606
logger . debug ( "putPolicy: " , putPolicy ) ;
605
607
logger . debug ( "get uphosts from: " , uphosts_url ) ;
606
- var ajax = that . createAjax ( ) ;
607
- ajax . open ( 'GET' , uphosts_url , false ) ;
608
- ajax . send ( ) ;
609
- if ( ajax . status === 200 ) {
610
- var res = that . parseJSON ( ajax . responseText ) ;
611
- qiniuUpHosts . http = getHosts ( res . http . up ) ;
612
- qiniuUpHosts . https = getHosts ( res . https . up ) ;
613
- logger . debug ( "get new uphosts: " , qiniuUpHosts ) ;
614
- that . resetUploadUrl ( ) ;
615
- } else {
616
- logger . error ( "get uphosts error: " , ajax . responseText ) ;
608
+ var ie = that . detectIEVersion ( ) ;
609
+ var ajax ;
610
+ if ( ie && ie <= 9 ) {
611
+ ajax = new mOxie . XMLHttpRequest ( ) ;
612
+ mOxie . Env . swf_url = op . flash_swf_url ;
613
+ } else {
614
+ ajax = that . createAjax ( ) ;
615
+ }
616
+ ajax . open ( 'GET' , uphosts_url , true ) ;
617
+ var onreadystatechange = function ( ) {
618
+ logger . debug ( "ajax.readyState: " , ajax . readyState ) ;
619
+ if ( ajax . readyState === 4 ) {
620
+ logger . debug ( "ajax.status: " , ajax . status ) ;
621
+ if ( ajax . status < 400 ) {
622
+ var res = that . parseJSON ( ajax . responseText ) ;
623
+ qiniuUpHosts . http = getHosts ( res . http . up ) ;
624
+ qiniuUpHosts . https = getHosts ( res . https . up ) ;
625
+ logger . debug ( "get new uphosts: " , qiniuUpHosts ) ;
626
+ that . resetUploadUrl ( ) ;
627
+ } else {
628
+ logger . error ( "get uphosts error: " , ajax . responseText ) ;
629
+ }
630
+ }
631
+ } ;
632
+ if ( ie && ie <= 9 ) {
633
+ ajax . bind ( 'readystatechange' , onreadystatechange ) ;
634
+ } else {
635
+ ajax . onreadystatechange = onreadystatechange ;
617
636
}
637
+ ajax . send ( ) ;
638
+ // ajax.send();
639
+ // if (ajax.status < 400) {
640
+ // var res = that.parseJSON(ajax.responseText);
641
+ // qiniuUpHosts.http = getHosts(res.http.up);
642
+ // qiniuUpHosts.https = getHosts(res.https.up);
643
+ // logger.debug("get new uphosts: ", qiniuUpHosts);
644
+ // that.resetUploadUrl();
645
+ // } else {
646
+ // logger.error("get uphosts error: ", ajax.responseText);
647
+ // }
618
648
return ;
619
649
} ;
620
650
@@ -926,7 +956,7 @@ function QiniuJsSDK() {
926
956
directUpload ( up , file , that . key_handler ) ;
927
957
} else {
928
958
// TODO: need a polifill to make it work in IE 9-
929
- // ISSUE: if file.name is existed in localStorage
959
+ // ISSUE: if file.name is existed in localStorage
930
960
// but not the same file maybe cause error
931
961
var localFileInfo = localStorage . getItem ( file . name ) ;
932
962
var blockSize = chunk_size ;
@@ -945,7 +975,7 @@ function QiniuJsSDK() {
945
975
946
976
if ( localFileInfo . percent !== 100 ) {
947
977
if ( file . size === localFileInfo . total ) {
948
- // TODO: if file.name and file.size is the same
978
+ // TODO: if file.name and file.size is the same
949
979
// but not the same file will cause error
950
980
file . percent = localFileInfo . percent ;
951
981
file . loaded = localFileInfo . offset ;
@@ -1226,7 +1256,7 @@ function QiniuJsSDK() {
1226
1256
1227
1257
var res = that . parseJSON ( info . response ) ;
1228
1258
ctx = ctx ? ctx : res . ctx ;
1229
- // if ctx is not empty
1259
+ // if ctx is not empty
1230
1260
// that means the upload strategy is chunk upload
1231
1261
// befroe the invoke the last_step
1232
1262
// we need request the mkfile to compose all uploaded chunks
0 commit comments