2020-04-26 19:09:43 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
|
|
|
|
use App\Events\LibraryChanged;
|
2022-07-29 06:47:10 +00:00
|
|
|
use App\Http\Controllers\Controller;
|
2020-04-26 19:09:43 +00:00
|
|
|
use App\Http\Requests\API\AlbumCoverUpdateRequest;
|
|
|
|
use App\Models\Album;
|
|
|
|
use App\Services\MediaMetadataService;
|
|
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
|
|
|
|
class AlbumCoverController extends Controller
|
|
|
|
{
|
2022-07-29 06:47:10 +00:00
|
|
|
public function __construct(private MediaMetadataService $mediaMetadataService)
|
2020-04-26 19:09:43 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function update(AlbumCoverUpdateRequest $request, Album $album)
|
|
|
|
{
|
|
|
|
$this->mediaMetadataService->writeAlbumCover(
|
|
|
|
$album,
|
|
|
|
$request->getFileContentAsBinaryString(),
|
|
|
|
$request->getFileExtension()
|
|
|
|
);
|
|
|
|
|
|
|
|
event(new LibraryChanged());
|
|
|
|
|
|
|
|
return new JsonResponse(['coverUrl' => $album->cover]);
|
|
|
|
}
|
|
|
|
}
|