feat: [file] path 기반 presigned URL 엔드포인트 추가
- POST /api/v1/files/presigned-url-by-path 추가 - file_id 없이 image_path만 있는 레거시 데이터 지원
This commit is contained in:
@@ -145,6 +145,21 @@ public function presignedUrl(int $id, Request $request)
|
||||
return ApiResponse::handle(fn () => ['url' => $url]);
|
||||
}
|
||||
|
||||
/**
|
||||
* R2 Presigned URL 발급 (file_path 기반, 30분 유효)
|
||||
*/
|
||||
public function presignedUrlByPath(Request $request)
|
||||
{
|
||||
$path = $request->input('path');
|
||||
if (! $path) {
|
||||
abort(400, 'path is required');
|
||||
}
|
||||
|
||||
$url = Storage::disk('r2')->temporaryUrl($path, now()->addMinutes(30));
|
||||
|
||||
return ApiResponse::handle(fn () => ['url' => $url]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Soft delete file
|
||||
*/
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
Route::get('/{id}/download', [FileStorageController::class, 'download'])->name('v1.files.download'); // 파일 다운로드
|
||||
Route::get('/{id}/view', [FileStorageController::class, 'view'])->name('v1.files.view'); // 파일 인라인 보기 (이미지/PDF)
|
||||
Route::get('/{id}/presigned-url', [FileStorageController::class, 'presignedUrl'])->name('v1.files.presigned-url'); // R2 Presigned URL 발급
|
||||
Route::post('/presigned-url-by-path', [FileStorageController::class, 'presignedUrlByPath'])->name('v1.files.presigned-url-by-path'); // R2 Presigned URL (path 기반)
|
||||
Route::delete('/{id}', [FileStorageController::class, 'destroy'])->name('v1.files.destroy'); // 파일 삭제 (soft)
|
||||
Route::post('/{id}/restore', [FileStorageController::class, 'restore'])->name('v1.files.restore'); // 파일 복구
|
||||
Route::delete('/{id}/permanent', [FileStorageController::class, 'permanentDelete'])->name('v1.files.permanent'); // 파일 영구 삭제
|
||||
|
||||
Reference in New Issue
Block a user