feat: R2 presigned URL 엔드포인트 추가
- FileStorageController에 presignedUrl() 메서드 추가 (30분 유효)
- GET /api/v1/files/{id}/presigned-url 라우트 추가
- 파일 프록시 스트리밍 대신 R2 직접 접근 지원
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
use App\Http\Requests\Api\V1\ShareLinkRequest;
|
||||
use App\Services\FileStorageService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class FileStorageController extends Controller
|
||||
{
|
||||
@@ -122,6 +123,28 @@ public function view(int $id, Request $request)
|
||||
return $file->download(inline: true);
|
||||
}
|
||||
|
||||
/**
|
||||
* R2 Presigned URL 발급 (30분 유효)
|
||||
*/
|
||||
public function presignedUrl(int $id, Request $request)
|
||||
{
|
||||
$this->ensureContext($request);
|
||||
|
||||
$service = new FileStorageService;
|
||||
$file = $service->getFile($id);
|
||||
|
||||
if (! $file->file_path || ! Storage::disk('r2')->exists($file->file_path)) {
|
||||
abort(404, 'File not found in storage');
|
||||
}
|
||||
|
||||
$url = Storage::disk('r2')->temporaryUrl(
|
||||
$file->file_path,
|
||||
now()->addMinutes(30)
|
||||
);
|
||||
|
||||
return ApiResponse::handle(fn () => ['url' => $url]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Soft delete file
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user