fix: [equipment] 사진 URL을 Signed URL로 변경 (비공개 GCS 버킷 대응)
- getPhotoUrls(): 공개 URL → GoogleCloudStorageService.getSignedUrl() 사용 - basic-info 탭: 동일하게 Signed URL로 변경 - URL 유효기간 120분
This commit is contained in:
@@ -23,7 +23,8 @@ class EquipmentPhotoService
|
||||
private const QUALITY_STEP = 5;
|
||||
|
||||
public function __construct(
|
||||
private readonly GoogleCloudService $googleCloudService
|
||||
private readonly GoogleCloudService $googleCloudService,
|
||||
private readonly GoogleCloudStorageService $googleCloudStorageService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -207,12 +208,11 @@ public function deletePhoto(Equipment $equipment, int $fileId): bool
|
||||
public function getPhotoUrls(Equipment $equipment): array
|
||||
{
|
||||
$photos = $equipment->photos()->get();
|
||||
$bucket = config('services.google.storage_bucket');
|
||||
|
||||
return $photos->map(function ($photo) use ($bucket) {
|
||||
return $photos->map(function ($photo) {
|
||||
$url = null;
|
||||
if ($photo->gcs_object_name && $bucket) {
|
||||
$url = "https://storage.googleapis.com/{$bucket}/{$photo->gcs_object_name}";
|
||||
if ($photo->gcs_object_name) {
|
||||
$url = $this->googleCloudStorageService->getSignedUrl($photo->gcs_object_name, 120);
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
@@ -91,9 +91,8 @@
|
||||
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3">
|
||||
@foreach($equipment->photos as $photo)
|
||||
@php
|
||||
$bucket = config('services.google.storage_bucket');
|
||||
$url = $photo->gcs_object_name && $bucket
|
||||
? "https://storage.googleapis.com/{$bucket}/{$photo->gcs_object_name}"
|
||||
$url = $photo->gcs_object_name
|
||||
? app(\App\Services\GoogleCloudStorageService::class)->getSignedUrl($photo->gcs_object_name, 120)
|
||||
: null;
|
||||
@endphp
|
||||
@if($url)
|
||||
|
||||
Reference in New Issue
Block a user