diff --git a/airtime_mvc/application/common/FileIO.php b/airtime_mvc/application/common/FileIO.php index 96cc73878..5b789228a 100644 --- a/airtime_mvc/application/common/FileIO.php +++ b/airtime_mvc/application/common/FileIO.php @@ -26,8 +26,16 @@ class Application_Common_FileIO } //Note that $size is allowed to be zero. If that's the case, it means we don't - //know the filesize, and we just won't send the Content-Length header. - if ($size < 0) { + //know the filesize, and we need to figure one out so modern browsers don't get + //confused. This should only affect files imported by legacy upstream since + //media monitor did not always set the proper size in the database but analyzer + //seems to always have a value for this. + if ($size === 0) { + $fstats = fstat($fm); + $size = $fstats['size']; + } + + if ($size <= 0) { throw new Exception("Invalid file size returned for file at $filePath"); } @@ -56,11 +64,9 @@ class Application_Common_FileIO header('Cache-Control: public, must-revalidate, max-age=0'); header('Pragma: no-cache'); header('Accept-Ranges: bytes'); - if ($size > 0) { - header('Content-Length:' . (($end - $begin) + 1)); - if (isset($_SERVER['HTTP_RANGE'])) { - header("Content-Range: bytes $begin-$end/$size"); - } + header('Content-Length:' . (($end - $begin) + 1)); + if (isset($_SERVER['HTTP_RANGE'])) { + header("Content-Range: bytes $begin-$end/$size"); } //We can have multiple levels of output buffering. Need to @@ -77,4 +83,4 @@ class Application_Common_FileIO } fclose($fm); } -} \ No newline at end of file +}