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 $base_dir = $config->{locations}->{base_dir};
my $tempDir = '/var/tmp'; my $tempDir = '/var/tmp';
my $uploadLimit = 200_000_000; my $uploadLimit = 300_000_000;
my %params = (); my %params = ();
my $error = ''; my $error = '';

View File

@@ -19,3 +19,10 @@ h2 {
th{ th{
text-align:center; 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 file = fileInput.files[0];
var size = file.size / (1000*1000); var size = file.size / (1000*1000);
$('#uploadSize').html(size + " MB"); $('#uploadSize').html(size + " MB");
if (size > 200){ if (size > 300){
$('#uploadButton').hide(); $('#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{ }else{
$('#uploadButton').show(); $('#uploadButton').show();
} }
@@ -46,7 +46,10 @@ function hideFinished(){
function roundSize(size){ function roundSize(size){
var MB=1000*1000; 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){ function uploadFile(uploadButton){
@@ -64,24 +67,37 @@ function uploadFile(uploadButton){
var start = new Date(); var start = new Date();
var myXhr = $.ajaxSettings.xhr(); var myXhr = $.ajaxSettings.xhr();
if (myXhr.upload) { if (myXhr.upload) {
var c=0;
var oldRemaining=0;
myXhr.upload.addEventListener( myXhr.upload.addEventListener(
'progress', 'progress',
function(data) { function(data) {
if (data.lengthComputable) { if (!data.lengthComputable) return;
var loaded=roundSize(data.loaded); c++;
var total=roundSize(data.total);
$('#progressBar').attr("value", loaded); var loaded=roundSize(data.loaded);
$('#progressBar').attr("max", total); var total=roundSize(data.total);
var duration=(new Date().getTime() - start.getTime()) / 1000 ; $('#progressBar').attr("value", loaded);
var bitrate = loaded / duration; $('#progressBar').attr("max", total);
var remaining = Math.round(100 * bitrate * ( total - loaded) );
var content = loaded + " of " + total + " MB<br>"; if (c<2)return;
content += '<div class="thin">'; c=0;
content += "finished in " + remaining + " seconds<br>";
content += "took " + Math.round(duration) + " seconds<br>"; var duration=(new Date().getTime() - start.getTime()) / 1000 ;
content += '</div>' var bitrate = loaded / duration;
$('#progressLabel').html(content);
} //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 false
); );

View File

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

View File

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