mirror of
https://github.com/koel/koel
synced 2024-12-30 06:23:05 +00:00
24 lines
599 B
PHP
24 lines
599 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Services\Streamer\Adapters;
|
||
|
|
||
|
use App\Models\Song;
|
||
|
|
||
|
class XSendFileStreamerAdapter extends LocalStreamerAdapter
|
||
|
{
|
||
|
/**
|
||
|
* Stream the current song using Apache's x_sendfile module.
|
||
|
*/
|
||
|
public function stream(Song $song, array $config = []): void
|
||
|
{
|
||
|
$path = $song->storage_metadata->getPath();
|
||
|
$contentType = 'audio/' . pathinfo($path, PATHINFO_EXTENSION);
|
||
|
|
||
|
header("X-Sendfile: $path");
|
||
|
header("Content-Type: $contentType");
|
||
|
header('Content-Disposition: inline; filename="' . basename($path) . '"');
|
||
|
|
||
|
exit;
|
||
|
}
|
||
|
}
|