From aea643d9ba4d0a2f7425a17c7764e46646f97652 Mon Sep 17 00:00:00 2001 From: nelsonlaquet Date: Sun, 1 Sep 2013 03:07:03 -0500 Subject: [PATCH 1/2] Added accel redirect support --- app/config/app.php | 2 ++ app/controllers/TracksController.php | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/config/app.php b/app/config/app.php index 5d065f3e..437338ca 100644 --- a/app/config/app.php +++ b/app/config/app.php @@ -2,6 +2,8 @@ return array( + 'sendfile' => false, + /* |-------------------------------------------------------------------------- | Application Debug Mode diff --git a/app/controllers/TracksController.php b/app/controllers/TracksController.php index 771fc7cb..103ba197 100644 --- a/app/controllers/TracksController.php +++ b/app/controllers/TracksController.php @@ -75,7 +75,13 @@ ResourceLogItem::logItem('track', $id, ResourceLogItem::PLAY, $format['index']); $response = Response::make('', 200); - $response->header('X-Sendfile', $track->getFileFor('MP3')); + + if (App::config('app.sendfile')) { + $response->header('X-Sendfile', $track->getFileFor('MP3')); + } else { + $response->header('X-Accel-Redirect', $track->getFileFor('MP3')); + } + $response->header('Content-Disposition', 'filename="' . $track->getFilenameFor('MP3') . '"'); $response->header('Content-Type', $format['mime_type']); @@ -104,7 +110,13 @@ ResourceLogItem::logItem('track', $id, ResourceLogItem::DOWNLOAD, $format['index']); $response = Response::make('', 200); - $response->header('X-Sendfile', $track->getFileFor($formatName)); + + if (App::config('app.sendfile')) { + $response->header('X-Sendfile', $track->getFileFor('MP3')); + } else { + $response->header('X-Accel-Redirect', $track->getFileFor('MP3')); + } + $response->header('Content-Disposition', 'attachment; filename="' . $track->getDownloadFilenameFor($formatName) . '"'); $response->header('Content-Type', $format['mime_type']); From 34aaa881d8257701b1e23e987c971d989647a46c Mon Sep 17 00:00:00 2001 From: nelsonlaquet Date: Sun, 1 Sep 2013 03:07:59 -0500 Subject: [PATCH 2/2] Fixed --- app/controllers/TracksController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/TracksController.php b/app/controllers/TracksController.php index 103ba197..10e074fb 100644 --- a/app/controllers/TracksController.php +++ b/app/controllers/TracksController.php @@ -76,7 +76,7 @@ $response = Response::make('', 200); - if (App::config('app.sendfile')) { + if (Config::get('app.sendfile')) { $response->header('X-Sendfile', $track->getFileFor('MP3')); } else { $response->header('X-Accel-Redirect', $track->getFileFor('MP3')); @@ -111,12 +111,12 @@ $response = Response::make('', 200); - if (App::config('app.sendfile')) { + if (Config::get('app.sendfile')) { $response->header('X-Sendfile', $track->getFileFor('MP3')); } else { $response->header('X-Accel-Redirect', $track->getFileFor('MP3')); } - + $response->header('Content-Disposition', 'attachment; filename="' . $track->getDownloadFilenameFor($formatName) . '"'); $response->header('Content-Type', $format['mime_type']);