From 8b7d932f00098d42b803dcf9f99755e7ff7bbb4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Fri, 13 Mar 2026 02:06:44 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20[storage]=20R2=20=EC=A0=95=EC=A0=81=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20=ED=94=84=EB=A1=9D=EC=8B=9C=20?= =?UTF-8?q?=EB=9D=BC=EC=9A=B0=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - /images/{path} 라우트로 R2에서 이미지 스트리밍 - bending 도면 이미지 등 정적 파일을 R2에서 서빙 - 캐시 1일 적용 (Cache-Control: max-age=86400) --- routes/web.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/routes/web.php b/routes/web.php index 4a72da16..bbf60395 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,6 +1,7 @@ exists($r2Path)) { + abort(404); + } + + $mime = Storage::disk('r2')->mimeType($r2Path); + $stream = Storage::disk('r2')->readStream($r2Path); + + return response()->stream(function () use ($stream) { + fpassthru($stream); + if (is_resource($stream)) { + fclose($stream); + } + }, 200, [ + 'Content-Type' => $mime, + 'Cache-Control' => 'public, max-age=86400', + ]); +})->where('path', '.*'); + // Swagger 설정 Route::get('/docs/api-docs.json', function () { return response()->file(storage_path('api-docs/api-docs.json'));