fix: [files] FileStorageController/ItemsFileController에 ensureContext 추가 (MNG 이미지 404 수정)

This commit is contained in:
2026-03-17 13:38:37 +09:00
parent 7083057d59
commit 8821509c99
2 changed files with 37 additions and 2 deletions

View File

@@ -12,6 +12,20 @@
class FileStorageController extends Controller
{
/**
* Bearer 토큰 없이 X-TENANT-ID 헤더로 컨텍스트 설정 (MNG 프록시 호출용)
*/
private function ensureContext(Request $request): void
{
if (! app()->bound('tenant_id') || ! app('tenant_id')) {
$tenantId = (int) ($request->header('X-TENANT-ID') ?: 287);
app()->instance('tenant_id', $tenantId);
}
if (! app()->bound('api_user') || ! app('api_user')) {
app()->instance('api_user', 1);
}
}
/**
* Upload file to temp
*/
@@ -85,8 +99,10 @@ public function trash()
/**
* Download file (attachment)
*/
public function download(int $id)
public function download(int $id, Request $request)
{
$this->ensureContext($request);
$service = new FileStorageService;
$file = $service->getFile($id);
@@ -96,8 +112,10 @@ public function download(int $id)
/**
* View file inline (이미지/PDF 브라우저에서 바로 표시)
*/
public function view(int $id)
public function view(int $id, Request $request)
{
$this->ensureContext($request);
$service = new FileStorageService;
$file = $service->getFile($id);