mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 00:54:15 +01:00
setting a bigger chunkSize for resumable to improve upload speed (has to be 2^N!)
This commit is contained in:
parent
e52f3493f1
commit
fc2cd455ca
@ -94,6 +94,12 @@ var et2_file = (function(){ "use strict"; return et2_inputWidget.extend(
|
||||
"type": "string",
|
||||
"default": '',
|
||||
"description": "Define types of files that the server accepts. Multiple types can be seperated by comma and the default is to accept everything."
|
||||
},
|
||||
chunk_size: {
|
||||
"name": "Chunk size",
|
||||
"type": "integer",
|
||||
"default": 1024*1024,
|
||||
"description": "Max chunk size, gets set from server-side PHP max_upload_size/2 (must be 2^N)"
|
||||
}
|
||||
},
|
||||
|
||||
@ -153,6 +159,7 @@ var et2_file = (function(){ "use strict"; return et2_inputWidget.extend(
|
||||
onError: function(event, name, error) { return self.onError(event,name,error);},
|
||||
beforeSend: function(form) { return self.beforeSend(form);},
|
||||
|
||||
chunkSize: this.options.chunk_size || 1024*1024,
|
||||
|
||||
target: egw.ajaxUrl("EGroupware\\Api\\Etemplate\\Widget\\File::ajax_upload"),
|
||||
query: function(file) {return self.beforeSend(file);},
|
||||
|
@ -339,4 +339,29 @@ class File extends Etemplate\Widget
|
||||
if($valid && !$this->attrs['multiple']) $valid = $valid[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default chunk_size attribute to max_upload_size/2
|
||||
*
|
||||
* @param string $cname
|
||||
* @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
|
||||
*/
|
||||
public function beforeSendToClient($cname, array $expand=null)
|
||||
{
|
||||
$form_name = self::form_name($cname, $this->id, $expand);
|
||||
|
||||
$upload_max_filesize = ini_get('upload_max_filesize');
|
||||
$unit = strtolower(substr($upload_max_filesize, -1));
|
||||
if (!is_numeric($unit)) $upload_max_filesize *= $unit == 'm' ? 1024*1024 : 1024;
|
||||
if ($upload_max_filesize > 1024*1024)
|
||||
{
|
||||
// resumable chunkSize has to be 2^N
|
||||
$n = 10;
|
||||
while(1<<(1+$n) < $upload_max_filesize-1024*1024)
|
||||
{
|
||||
$n++;
|
||||
}
|
||||
self::setElementAttribute($form_name, 'chunk_size', 1 << $n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user