mirror of
https://github.com/koel/koel
synced 2024-12-01 08:19:18 +00:00
25 lines
691 B
PHP
25 lines
691 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
use App\Events\LibraryChanged;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\API\UploadAlbumCoverRequest;
|
|
use App\Models\Album;
|
|
use App\Services\MediaMetadataService;
|
|
|
|
class UploadAlbumCoverController extends Controller
|
|
{
|
|
public function __invoke(UploadAlbumCoverRequest $request, Album $album, MediaMetadataService $mediaMetadataService)
|
|
{
|
|
$mediaMetadataService->writeAlbumCover(
|
|
$album,
|
|
$request->getFileContentAsBinaryString(),
|
|
$request->getFileExtension()
|
|
);
|
|
|
|
event(new LibraryChanged());
|
|
|
|
return response()->json(['coverUrl' => $album->cover]);
|
|
}
|
|
}
|