Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
4 / 4 |
| DownloadFileController | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
4 / 4 |
| download | |
100.00% |
1 / 1 |
2 | |
100.00% |
4 / 4 |
|||
| <?php | |
| namespace BristolSU\Module\UploadFile\Http\Controllers; | |
| use BristolSU\Module\UploadFile\Models\File; | |
| use BristolSU\Support\Activity\Activity; | |
| use BristolSU\Support\ModuleInstance\ModuleInstance; | |
| use Illuminate\Http\Request; | |
| use Illuminate\Support\Facades\Storage; | |
| use Symfony\Component\HttpKernel\Exception\HttpException; | |
| class DownloadFileController extends Controller | |
| { | |
| public function download(Request $request, Activity $activity, ModuleInstance $moduleInstance, File $file) | |
| { | |
| $this->authorize('file.download'); | |
| if(Storage::exists($file->path)) { | |
| return Storage::download($file->path, $file->filename); | |
| } | |
| throw new HttpException(404, 'File not found'); | |
| } | |
| } |