Download attachments
This commit is contained in:
@ -7,6 +7,7 @@ use Psr\Http\Message\ServerRequestInterface;
|
||||
use ProVM\Common\Implement\Controller\Json;
|
||||
use ProVM\Common\Service\Attachments as Service;
|
||||
use ProVM\Emails\Model\Attachment;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Attachments
|
||||
{
|
||||
@ -51,4 +52,13 @@ class Attachments
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function get(ServerRequestInterface $request, ResponseInterface $response, Service $service, LoggerInterface $logger, int $attachment_id): ResponseInterface
|
||||
{
|
||||
$attachment = $service->getRepository()->fetchById($attachment_id);
|
||||
|
||||
$response->withHeader('Content-Type', 'application/pdf');
|
||||
$response->withHeader('Content-Disposition', "'attachment;filename='{$attachment->getFullFilename()}'");
|
||||
$response->getBody()->write($service->getFile($attachment_id));
|
||||
return $response;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user