fix(core,admin_basic): S3 스토리지 드라이버 실동작 결함 수정 및 S3 호환 스토리지 연결 지원
공개 제보 — 파일 스토리지에서 S3 를 선택해 저장해도 실제 파일 저장이 동작하지 않던 결함의 전면 수정. - S3 어댑터(league/flysystem-aws-s3-v3)·predis 를 코어 기본 의존성으로 포함 — 어댑터 부재 즉사, phpredis 확장 없는 서버의 redis 선택 전면 다운 차단 (부트 시 확장 부재 감지 → predis 자동 폴백) - storage_driver=s3 저장 시 코어 첨부 업로드 디스크를 s3 로 전환 (ATTACHMENT_DISK env 명시가 항상 우선, 기존 행은 저장 당시 disk 로 서빙) - 첨부·템플릿 레이아웃 첨부 서빙을 행 disk 를 따르는 스토리지 스트림으로 교체 — 로컬 절대 경로 전제 fileResponse 는 S3 행에서 filemtime stat 500 (streamedFileResponse: 행 메타 기반 ETag/304/Cache-Control) - S3 호환 스토리지(R2/MinIO/NCP) 연결 지원: 엔드포인트 URL·path-style 설정 신설, 리전 목록 선택 → 자유 입력 전환, 연결 테스트를 실제 저장 경로와 동일 설정(endpoint/path-style)으로 정렬 - 사용 불능 드라이버(어댑터·PHP 확장 부재)의 저장/테스트 요청을 사유와 함께 422 로 차단하는 서버 게이트 신설 (DriverRegistryService 능력 판정) - 웹소켓 연결 테스트에 서버(백엔드 발송용) endpoint 검사 추가 — 클라이언트만 검사해 테스트 성공 + 실제 발송 실패가 가능하던 비대칭 해소 - env 빈 값(`KEY=`) 함정 정규화: AWS_URL/AWS_ENDPOINT/ATTACHMENT_DISK 빈 문자열을 미설정으로 취급 (config 정규화 + 예시 파일 주석 처리) - 플러그인 드라이버 폴백의 log 카테고리 죽은 키(logging.default) 정정 및 websocket 유령 설정 키 제거 - 실 AWS S3 종단 검증 완료 (설정 저장 → 업로드 S3 실저장 → 서빙 200/304)
This commit is contained in:
1 parent
c128a6ea3a
commit
ea58c606a2
56 files changed
+2899
-243
No files matched your search
@@ -270,12 +270,15 @@ class AttachmentService
|
||||
/**
|
||||
* 이미지 파일 정보 조회 (캐싱 응답용)
|
||||
*
|
||||
* 권한 체크 후 파일 경로와 메타 정보를 반환합니다.
|
||||
* 컨트롤러에서 fileResponse()로 캐싱 헤더와 함께 응답할 수 있습니다.
|
||||
* 권한 체크 후 인라인 스트림 응답과 캐싱용 메타를 반환합니다.
|
||||
* 로컬 절대 경로 조립(getBasePath) 방식은 S3 등 원격 디스크 행에서 성립하지
|
||||
* 않으므로(#99 — filemtime stat 실패 500), 행 disk 를 그대로 따르는
|
||||
* StorageInterface::response() 스트림으로 서빙합니다. 컨트롤러는
|
||||
* streamedFileResponse() 로 캐싱 헤더(ETag/304)를 입혀 응답합니다.
|
||||
*
|
||||
* @param string $hash 첨부파일 해시
|
||||
* @param User|null $user 요청한 사용자 (null이면 비로그인)
|
||||
* @return array{path: string, mime_type: string, filename: string}|null 파일 정보 또는 null
|
||||
* @return array{response: StreamedResponse, etag_source: string, mime_type: string, filename: string}|null 서빙 정보 또는 null
|
||||
*
|
||||
* @throws AuthorizationException 기능 레벨 권한이 없는 경우
|
||||
*/
|
||||
@@ -293,9 +296,19 @@ class AttachmentService
|
||||
// 필터 훅 - 다운로드 전 처리
|
||||
$attachment = HookManager::applyFilters('core.attachment.before_download', $attachment, $user);
|
||||
|
||||
// 파일 존재 확인
|
||||
$diskStorage = $this->storage->withDisk($attachment->disk);
|
||||
if (! $diskStorage->exists('', $attachment->path)) {
|
||||
// 행 disk 기준 인라인 스트림 (존재 검사는 response() 내부에서 수행)
|
||||
// Content-Type/Length 를 행 메타로 선지정해 원격 디스크의 추가 메타 조회를 생략한다.
|
||||
$response = $this->storage->withDisk($attachment->disk)->response(
|
||||
'',
|
||||
$attachment->path,
|
||||
$attachment->original_filename,
|
||||
[
|
||||
'Content-Type' => $attachment->mime_type,
|
||||
'Content-Length' => (string) $attachment->size,
|
||||
]
|
||||
);
|
||||
|
||||
if (! $response) {
|
||||
Log::error('첨부파일 스토리지에 없음', [
|
||||
'attachment_id' => $attachment->id,
|
||||
'path' => $attachment->path,
|
||||
@@ -305,7 +318,14 @@ class AttachmentService
|
||||
}
|
||||
|
||||
return [
|
||||
'path' => $diskStorage->getBasePath('').DIRECTORY_SEPARATOR.$attachment->path,
|
||||
'response' => $response,
|
||||
// 파일 stat 없이 결정적인 ETag 소스 (업로드 파일은 경로당 불변)
|
||||
'etag_source' => implode('|', [
|
||||
$attachment->disk,
|
||||
$attachment->path,
|
||||
(string) $attachment->updated_at?->getTimestamp(),
|
||||
(string) $attachment->size,
|
||||
]),
|
||||
'mime_type' => $attachment->mime_type,
|
||||
'filename' => $attachment->original_filename,
|
||||
];
|
||||
|
||||
Reference in new issue
Block a user