feat:APK 파일 다운로드 링크 추가
- APK 파일명 클릭 시 다운로드, download_count 자동 증가 - app_releases 디스크 스트리밍 다운로드 라우트 추가 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,10 +2,13 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\AppVersion;
|
||||
use App\Services\AppVersionService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class AppVersionController extends Controller
|
||||
{
|
||||
@@ -71,6 +74,26 @@ public function update(Request $request, int $id): RedirectResponse
|
||||
->with('success', '버전이 수정되었습니다.');
|
||||
}
|
||||
|
||||
/**
|
||||
* APK 다운로드
|
||||
*/
|
||||
public function download(int $id): StreamedResponse
|
||||
{
|
||||
$version = AppVersion::findOrFail($id);
|
||||
|
||||
if (! $version->apk_path || ! Storage::disk('app_releases')->exists($version->apk_path)) {
|
||||
abort(404, 'APK 파일을 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
$version->increment('download_count');
|
||||
|
||||
$fileName = $version->apk_original_name ?: "sam-v{$version->version_name}.apk";
|
||||
|
||||
return Storage::disk('app_releases')->download($version->apk_path, $fileName, [
|
||||
'Content-Type' => 'application/vnd.android.package-archive',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 활성 토글
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user