| Conditions | 1 |
| Paths | 1 |
| Total Lines | 13 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | public function stream(): void |
||
| 13 | { |
||
| 14 | $relativePath = str_replace(Setting::get('media_path'), '', $this->song->path); |
||
| 15 | |||
| 16 | // We send our media_path value as a 'X-Media-Root' header to downstream (nginx) |
||
| 17 | // It will then be use as `alias` in X-Accel config location block. |
||
| 18 | // See nginx.conf.example. |
||
| 19 | header('X-Media-Root: '.Setting::get('media_path')); |
||
| 20 | header("X-Accel-Redirect: /media/$relativePath"); |
||
| 21 | header("Content-Type: {$this->contentType}"); |
||
| 22 | header('Content-Disposition: inline; filename="'.basename($this->song->path).'"'); |
||
| 23 | |||
| 24 | exit; |
||
| 25 | } |
||
| 27 |