fix: guest upload >5 files. change: chunk size change with speed, operate box in middle.
parent
1737477aed
commit
7e4bf448e3
|
@ -941,7 +941,9 @@
|
|||
} else {
|
||||
filemd5 = spark.end();
|
||||
td2.innerHTML='md5: '+filemd5;
|
||||
delete uploading[upbigfilename];
|
||||
upbigfilename = filemd5+ext;
|
||||
uploading[upbigfilename] = i;
|
||||
<!--GuestEnd-->
|
||||
td2.innerHTML='<!--constStr@GetUploadLink--> ...';
|
||||
var xhr1 = new XMLHttpRequest();
|
||||
|
@ -1005,6 +1007,7 @@
|
|||
var newstartsize = 0;
|
||||
if(!!file){
|
||||
var asize=0;
|
||||
var chunksize=10*1024*1024; // chunk size, max 60M. 每小块上传大小,最大60M,微软建议10M
|
||||
var totalsize=file.size;
|
||||
var xhr2 = new XMLHttpRequest();
|
||||
xhr2.open("GET", url);
|
||||
|
@ -1022,8 +1025,6 @@
|
|||
} else {
|
||||
StartStr='<!--constStr@LastUpload-->'+size_format(newstartsize)+ '<br><!--constStr@ThisTime--><!--constStr@UploadStartAt-->:' +StartTime.toLocaleString()+'<br>' ;
|
||||
}
|
||||
var chunksize=5*1024*1024; // chunk size, max 60M. 每小块上传大小,最大60M,微软建议10M
|
||||
if (totalsize>200*1024*1024) chunksize=10*1024*1024;
|
||||
function readblob(start) {
|
||||
var end=start+chunksize;
|
||||
var blob = file.slice(start,end);
|
||||
|
@ -1033,6 +1034,7 @@
|
|||
|
||||
reader.onload = function(e){
|
||||
var binary = this.result;
|
||||
var lastCurrentSpeed;
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("PUT", url, true);
|
||||
//xhr.setRequestHeader('x-requested-with','XMLHttpRequest');
|
||||
|
@ -1040,9 +1042,10 @@
|
|||
xhr.setRequestHeader('Content-Range', 'bytes ' + asize + '-' + bsize +'/'+ totalsize);
|
||||
xhr.upload.onprogress = function(e){
|
||||
if (e.lengthComputable) {
|
||||
var tmptime = new Date();
|
||||
var tmpspeed = e.loaded*1000/(tmptime.getTime()-C_starttime.getTime());
|
||||
var remaintime = (totalsize-asize-e.loaded)/tmpspeed;
|
||||
let tmptime = new Date();
|
||||
let tmpspeed = e.loaded*1000/(tmptime.getTime()-C_starttime.getTime());
|
||||
lastCurrentSpeed = tmpspeed;
|
||||
let remaintime = (totalsize-asize-e.loaded)/tmpspeed;
|
||||
label.innerHTML=StartStr+'<!--constStr@Upload--> ' +size_format(asize+e.loaded)+ ' / '+size_format(totalsize) + ' = ' + ((asize+e.loaded)*100/totalsize).toFixed(2) + '% <!--constStr@AverageSpeed-->:'+size_format((asize+e.loaded-newstartsize)*1000/(tmptime.getTime()-StartTime.getTime()))+'/s<br><!--constStr@CurrentSpeed--> '+size_format(tmpspeed)+'/s <!--constStr@Expect--> '+seconds2hour(remaintime.toFixed(1));
|
||||
}
|
||||
}
|
||||
|
@ -1086,6 +1089,9 @@
|
|||
} else {
|
||||
var a=response['nextExpectedRanges'][0];
|
||||
asize=Number( a.slice(0,a.indexOf("-")) );
|
||||
chunksize = 10*1024*1024;
|
||||
if (lastCurrentSpeed>5*1024*1024) chunksize = 20*1024*1024;
|
||||
if (lastCurrentSpeed>10*1024*1024) chunksize = 50*1024*1024;
|
||||
readblob(asize);
|
||||
}
|
||||
} } else readblob(asize);
|
||||
|
@ -1158,7 +1164,6 @@
|
|||
uploading[upbigfilename] = [i];
|
||||
var spark = sha1.create();
|
||||
var reader = new FileReader();
|
||||
var chunksize=10*1024*1024;
|
||||
var asize = 0;
|
||||
var filesha1;
|
||||
function readblob(start) {
|
||||
|
@ -1479,15 +1484,15 @@
|
|||
document.getElementById(action + '_fileid').value=fileid;
|
||||
document.getElementById(action + '_hidden').value=str;
|
||||
if (action=='rename') document.getElementById(action + '_input').value=str;
|
||||
var $e = event || window.event;
|
||||
var $scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
|
||||
/*var $e = event || window.event;
|
||||
var $scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;*/
|
||||
var $scrollY = document.documentElement.scrollTop || document.body.scrollTop;
|
||||
var $x = $e.pageX || $e.clientX + $scrollX;
|
||||
/*var $x = $e.pageX || $e.clientX + $scrollX;
|
||||
var $y = $e.pageY || $e.clientY + $scrollY;
|
||||
if (action=='create') {
|
||||
if (action=='create') {*/
|
||||
document.getElementById(action + '_div').style.left=(document.body.clientWidth-document.getElementById(action + '_div').offsetWidth)/2 +'px';
|
||||
document.getElementById(action + '_div').style.top=(window.innerHeight-document.getElementById(action + '_div').offsetHeight)/2+$scrollY +'px';
|
||||
} else {
|
||||
/*} else {
|
||||
if ($x + document.getElementById(action + '_div').offsetWidth > document.body.clientWidth) {
|
||||
if (document.getElementById(action + '_div').offsetWidth > document.body.clientWidth) {
|
||||
document.getElementById(action + '_div').offsetWidth=document.body.clientWidth+'px';
|
||||
|
@ -1499,7 +1504,7 @@
|
|||
document.getElementById(action + '_div').style.left=$x+'px';
|
||||
}
|
||||
document.getElementById(action + '_div').style.top=$y+'px';
|
||||
}
|
||||
}*/
|
||||
document.getElementById(action + '_input').focus();
|
||||
}
|
||||
function submit_operate(str) {
|
||||
|
|
Loading…
Reference in New Issue