feat: [file] API Resource에서 image_url (presigned URL) 반환
- File 모델에 presignedUrl() 메서드 추가 - GuiderailModelResource: image_url + components[].image_url 반환 - BendingItemResource: image_url 반환 - 소비자(MNG, React)가 별도 처리 없이 R2 직접 로드 가능
This commit is contained in:
@@ -98,6 +98,21 @@ public function fileable()
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
/**
|
||||
* R2 Presigned URL 생성 (30분 유효)
|
||||
*/
|
||||
public function presignedUrl(int $minutes = 30): ?string
|
||||
{
|
||||
if (! $this->file_path) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Storage::disk('r2')->temporaryUrl(
|
||||
$this->file_path,
|
||||
now()->addMinutes($minutes)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the full storage path
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user