Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 8 |
| SessionController | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 8 |
| download | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 8 |
|||
| 1 | <?php |
| 2 | |
| 3 | namespace Qmp\Laravel\ApiGateway\Controllers\Deduplication; |
| 4 | |
| 5 | use Illuminate\Http\Response; |
| 6 | use Illuminate\Support\Facades\Storage; |
| 7 | use Illuminate\Http\Request; |
| 8 | use Illuminate\Support\Facades\Log; |
| 9 | use Qmp\Laravel\ApiGateway\Controllers\AbstractApiController; |
| 10 | |
| 11 | class SessionController extends AbstractApiController |
| 12 | { |
| 13 | |
| 14 | protected $externalAuthAcceptedMethods = ['download']; |
| 15 | |
| 16 | protected $serviceName = 'service_deduplication'; |
| 17 | |
| 18 | protected $resourceName = 'session'; |
| 19 | |
| 20 | protected $methodsWithoutJsonMiddleware = ['download']; |
| 21 | |
| 22 | public function download(Request $request, $id) |
| 23 | { |
| 24 | $response = $this->getResponseFromService( |
| 25 | $this->serviceName, |
| 26 | "{$this->resourceName}/$id/download", |
| 27 | ['query' => $request->all()] |
| 28 | ); |
| 29 | |
| 30 | if (isset($response->content['path'])) { |
| 31 | $filename = Storage::disk('deduplication')->path($response->content['path']); |
| 32 | return $this->fileResponse($filename); |
| 33 | } else { |
| 34 | return $this->response(['error' => 'Unauthorized'], 422); |
| 35 | } |
| 36 | } |
| 37 | } |