koel/app/Http/Streamers/XSendFileStreamer.php
2016-02-02 16:01:47 +08:00

25 lines
560 B
PHP

<?php
namespace App\Http\Streamers;
use App\Models\Song;
class XSendFileStreamer extends Streamer implements StreamerInterface
{
public function __construct(Song $song)
{
parent::__construct($song);
}
/**
* Stream the current song using Apache's x_sendfile module.
*/
public function stream()
{
header("X-Sendfile: {$this->song->path}");
header("Content-Type: {$this->contentType}");
header('Content-Disposition: inline; filename="'.basename($this->song->path).'"');
exit;
}
}