Add a persisted instance setting for S3 image CDN URLs and use it when building image links. Cache profile avatars and project icons with immutable one-year headers.
23 lines
673 B
PHP
23 lines
673 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Project;
|
|
use App\Services\ProjectIconStorageService;
|
|
use Illuminate\Http\Response;
|
|
|
|
class ProjectIconController extends Controller
|
|
{
|
|
public function __invoke(string $project_uuid, ProjectIconStorageService $iconStorage): Response
|
|
{
|
|
$project = Project::ownedByCurrentTeam()->where('uuid', $project_uuid)->firstOrFail();
|
|
$contents = $iconStorage->projectContents($project);
|
|
|
|
abort_if($contents === null, 404);
|
|
|
|
return response($contents, 200, [
|
|
'Content-Type' => 'image/jpeg',
|
|
'Cache-Control' => 'private, max-age=31536000, immutable',
|
|
]);
|
|
}
|
|
}
|