Conditions | 1 |
Paths | 1 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
28 | public function __invoke(DownloadMedia $query): Response |
||
29 | { |
||
30 | $media = $this->getMedia($query); |
||
31 | |||
32 | $output = fopen('php://output', 'wb'); |
||
33 | |||
34 | $response = new StreamedResponse(function () use ($media, $output) { |
||
35 | $this->storage->streamTo($media, $output); |
||
36 | }); |
||
37 | |||
38 | $file = $media->file(); |
||
39 | |||
40 | $disposition = $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $file->basename()); |
||
41 | |||
42 | $response->headers->set('Content-Length', $file->info()->fileSize()); |
||
43 | $response->headers->set('Content-Type', $file->info()->mimeType()); |
||
44 | $response->headers->set('Content-Disposition', $disposition); |
||
45 | |||
46 | return $response; |
||
47 | } |
||
49 |