mirror of
https://github.com/koel/koel
synced 2024-12-24 19:43:06 +00:00
33 lines
828 B
PHP
33 lines
828 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Controllers\API;
|
||
|
|
||
|
use App\Events\LibraryChanged;
|
||
|
use App\Http\Requests\API\AlbumCoverUpdateRequest;
|
||
|
use App\Models\Album;
|
||
|
use App\Services\MediaMetadataService;
|
||
|
use Illuminate\Http\JsonResponse;
|
||
|
|
||
|
class AlbumCoverController extends Controller
|
||
|
{
|
||
|
private $mediaMetadataService;
|
||
|
|
||
|
public function __construct(MediaMetadataService $mediaMetadataService)
|
||
|
{
|
||
|
$this->mediaMetadataService = $mediaMetadataService;
|
||
|
}
|
||
|
|
||
|
public function update(AlbumCoverUpdateRequest $request, Album $album)
|
||
|
{
|
||
|
$this->mediaMetadataService->writeAlbumCover(
|
||
|
$album,
|
||
|
$request->getFileContentAsBinaryString(),
|
||
|
$request->getFileExtension()
|
||
|
);
|
||
|
|
||
|
event(new LibraryChanged());
|
||
|
|
||
|
return new JsonResponse(['coverUrl' => $album->cover]);
|
||
|
}
|
||
|
}
|