Make sure to clean the response before returning files

Was a problemw when returning images and there were leading empty lines in config.php which seem to get added to the response always...
This commit is contained in:
Bernd Bestel
2021-07-12 15:34:26 +02:00
parent 6659a5cd08
commit 2cc4f4d382
2 changed files with 3 additions and 0 deletions

View File

@@ -49,6 +49,7 @@ class FilesApiController extends BaseApiController
if (file_exists($filePath))
{
ob_clean(); // Make sure to ONLY return the file
$response->write(file_get_contents($filePath));
$response = $response->withHeader('Cache-Control', 'max-age=2592000');
$response = $response->withHeader('Content-Type', mime_content_type($filePath));
@@ -80,6 +81,7 @@ class FilesApiController extends BaseApiController
if (file_exists($filePath))
{
ob_clean(); // Make sure to ONLY return the file
$response->write(file_get_contents($filePath));
$response = $response->withHeader('Cache-Control', 'max-age=2592000');
$response = $response->withHeader('Content-Type', mime_content_type($filePath));