Skip to content

Commit

Permalink
Fix file reuturn message on broken files
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelfolaron committed Aug 29, 2024
1 parent a0cbf62 commit 46a5179
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/Domain/Files/Controllers/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Leantime\Domain\Files\Controllers;

use Aws\S3\S3Client;
use Illuminate\Support\Facades\Log;
use Leantime\Core\Configuration\Environment;
use Leantime\Core\Controller\Controller;
use Leantime\Domain\Files\Repositories\Files as FileRepository;
Expand Down Expand Up @@ -116,7 +117,10 @@ private function getFileLocally($encName, $ext, $module, $realName): Response
$oStreamResponse->headers->set("Pragma", 'public');
$oStreamResponse->headers->set("Cache-Control", 'max-age=86400');
$oStreamResponse->headers->set("Last-Modified", gmdate("D, d M Y H:i:s", $sLastModified) . " GMT");
}else{
error_log("not caching");
}

$oStreamResponse->setCallback(function () use ($fullPath) {
readfile($fullPath);
});
Expand Down Expand Up @@ -181,11 +185,12 @@ private function getFileFromS3($encName, $ext, $module, $realName): Response
$response->headers->set('Content-Disposition', "inline; filename=\"" . $realName . "." . $ext . "\"");

return $response;

} catch (\Exception $e) {

report($e);
Log::error($e);

return new Response($e->getMessage(), 500);
return new Response("File cannot be found", 400);
}
}
}

0 comments on commit 46a5179

Please sign in to comment.