increase upload limit

remaining upload time will be calculated more simple
This commit is contained in:
Milan
2018-10-05 00:17:21 +02:00
parent 7ff41cecd2
commit 1f9cd04914
5 changed files with 47 additions and 28 deletions

View File

@@ -34,7 +34,7 @@ our $debug = $config->{system}->{debug};
my $base_dir = $config->{locations}->{base_dir};
my $tempDir = '/var/tmp';
my $uploadLimit = 200_000_000;
my $uploadLimit = 300_000_000;
my %params = ();
my $error = '';

View File

@@ -19,3 +19,10 @@ h2 {
th{
text-align:center;
}
#progressBar{
width:100%;
height:1rem;
border:0;
box-shadow:#888 2px 2px 1px 1px;
}

View File

@@ -18,9 +18,9 @@ function changeFile(fileInput){
var file = fileInput.files[0];
var size = file.size / (1000*1000);
$('#uploadSize').html(size + " MB");
if (size > 200){
if (size > 300){
$('#uploadButton').hide();
showError("file is too large. maximum size is 200 MB! Please use MP3, 192 kHz, CBR, 44100 Hz, 16bit");
showError("file is too large. maximum size is 300 MB! Please use MP3, 192 kHz, CBR, 44100 Hz, 16bit");
}else{
$('#uploadButton').show();
}
@@ -46,7 +46,10 @@ function hideFinished(){
function roundSize(size){
var MB=1000*1000;
return Math.round(size*10/MB)/10;
var value= Math.round(size*10/MB)/10;
value+='';
if (value.indexOf('.')<0)value+='.0';
return value;
}
function uploadFile(uploadButton){
@@ -64,24 +67,37 @@ function uploadFile(uploadButton){
var start = new Date();
var myXhr = $.ajaxSettings.xhr();
if (myXhr.upload) {
var c=0;
var oldRemaining=0;
myXhr.upload.addEventListener(
'progress',
function(data) {
if (data.lengthComputable) {
var loaded=roundSize(data.loaded);
var total=roundSize(data.total);
$('#progressBar').attr("value", loaded);
$('#progressBar').attr("max", total);
var duration=(new Date().getTime() - start.getTime()) / 1000 ;
var bitrate = loaded / duration;
var remaining = Math.round(100 * bitrate * ( total - loaded) );
var content = loaded + " of " + total + " MB<br>";
content += '<div class="thin">';
content += "finished in " + remaining + " seconds<br>";
content += "took " + Math.round(duration) + " seconds<br>";
content += '</div>'
$('#progressLabel').html(content);
}
if (!data.lengthComputable) return;
c++;
var loaded=roundSize(data.loaded);
var total=roundSize(data.total);
$('#progressBar').attr("value", loaded);
$('#progressBar').attr("max", total);
if (c<2)return;
c=0;
var duration=(new Date().getTime() - start.getTime()) / 1000 ;
var bitrate = loaded / duration;
//var remaining = Math.round(bitrate * ( total - loaded) );
var remaining = Math.round( (duration * data.total / data.loaded) - duration );
if (oldRemaining == 0) oldRemaining = remaining;
if (duration>30) remaining= oldRemaining*0.5 + remaining*0.5;
oldRemaining=remaining;
var content = loaded + " of " + total + " MB<br>";
content += '<div class="thin">';
content += "finished in " + Math.round(remaining) + " seconds<br>";
content += "took " + Math.round(duration) + " seconds<br>";
content += '</div>'
$('#progressLabel').html(content);
} ,
false
);

View File

@@ -118,7 +118,6 @@
</TMPL_IF>
-->
</div>
</center>
</main>
</body>
</html>

View File

@@ -18,9 +18,10 @@ binmode STDOUT, ":encoding(UTF-8)";
if ( $0 =~ /upload_playout.*?\.cgi$/ ) {
# read POST content
my ( $buf, $content );
while ( $r->read( $buf, 8192 ) ) {
$content .= $buf;
my $buffer = '';
my $content = '';
while ( $r->read( $buffer, 65536 ) ) {
$content .= $buffer;
}
$content = "{}" unless $content;
@@ -29,7 +30,6 @@ if ( $0 =~ /upload_playout.*?\.cgi$/ ) {
my $config = config::getFromScriptLocation();
my $debug = $config->{system}->{debug};
my $len = $r->headers_in()->get('Content-Length');
print "Content-type:text/plain\n\n";
my $json = JSON::decode_json($content);
@@ -39,9 +39,6 @@ if ( $0 =~ /upload_playout.*?\.cgi$/ ) {
my $result = playout::sync( $config, $json );
$config->{access}->{write} = 0;
#print Dumper($content)."\n";
#print Dumper($r);
#print Dumper($json);
print "upload playout result:" . Dumper($result);
}