Download attachments

This commit is contained in:
2022-11-29 11:12:06 -03:00
parent c53eb4c7a6
commit f8500e061c
21 changed files with 242 additions and 27 deletions

View File

@ -0,0 +1,21 @@
<?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;
}
}