mirror of
https://github.com/koel/koel
synced 2024-12-18 16:44:03 +00:00
23 lines
599 B
PHP
23 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;
|
|
}
|
|
}
|