schneespur/app/Http/Controllers/StorageFallbackController.php
Michael ee3dbba6cc Initial release v1.0.0
Schneespur — Open-source winter service documentation software (PWA + Admin).
GPS tracking via OwnTracks, weather data, photo evidence, and legally
compliant service records for winter maintenance operators.

License: AGPL-3.0-or-later
2026-05-17 13:33:51 +00:00

27 lines
731 B
PHP

<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Storage;
use Symfony\Component\HttpFoundation\Response;
class StorageFallbackController extends Controller
{
public function __invoke(string $path): Response
{
$disk = Storage::disk('public');
if (! $disk->exists($path)) {
abort(404);
}
$mimeType = $disk->mimeType($path) ?: 'application/octet-stream';
$lastModified = $disk->lastModified($path);
return response($disk->get($path), 200, [
'Content-Type' => $mimeType,
'Cache-Control' => 'public, max-age=604800',
'Last-Modified' => gmdate('D, d M Y H:i:s', $lastModified) . ' GMT',
]);
}
}