Files
emails/ui/common/Controller/Attachments.php
2022-11-29 11:12:06 -03:00

21 lines
721 B
PHP

<?php
namespace ProVM\Common\Controller;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Client\ClientInterface;
use Psr\Log\LoggerInterface;
class Attachments
{
public function get(ServerRequestInterface $request, ResponseInterface $response, ClientInterface $client, LoggerInterface $logger, int $attachment_id): ResponseInterface
{
$rs = $client->get("/attachment/{$attachment_id}", [
'stream' => true,
'sink' => \Safe\fopen('php://stdout', 'wb')
]);
$response->withHeader('Content-Type', 'application/pdf');
$response->getBody()->write($rs->getBody()->getContents());
return $response;
}
}