This commit is contained in:
Yuri Kuznetsov
2022-11-29 17:56:45 +02:00
parent f2ea162952
commit 39c0f159a8
2 changed files with 25 additions and 19 deletions
@@ -29,10 +29,12 @@
namespace Espo\Core\EntryPoint;
use Espo\Core\{
Api\Request,
Api\Response,
};
use Espo\Core\Api\Request;
use Espo\Core\Api\Response;
use Espo\Core\Exceptions\BadRequest;
use Espo\Core\Exceptions\Error;
use Espo\Core\Exceptions\Forbidden;
use Espo\Core\Exceptions\NotFound;
/**
* An entry point to the application by `?entryPoint={entityPointName}` URI.
@@ -40,5 +42,11 @@ use Espo\Core\{
*/
interface EntryPoint
{
/**
* @throws Error
* @throws Forbidden
* @throws BadRequest
* @throws NotFound
*/
public function run(Request $request, Response $response): void;
}
+13 -15
View File
@@ -30,18 +30,16 @@
namespace Espo\EntryPoints;
use Espo\Entities\Attachment as AttachmentEntity;
use Espo\Core\{
Exceptions\BadRequest,
Exceptions\Forbidden,
Exceptions\NotFoundSilent,
EntryPoint\EntryPoint,
Acl,
ORM\EntityManager,
Api\Request,
Api\Response,
FileStorage\Manager as FileStorageManager,
Utils\Metadata};
use Espo\Core\Acl;
use Espo\Core\Api\Request;
use Espo\Core\Api\Response;
use Espo\Core\EntryPoint\EntryPoint;
use Espo\Core\Exceptions\BadRequest;
use Espo\Core\Exceptions\Forbidden;
use Espo\Core\Exceptions\NotFoundSilent;
use Espo\Core\FileStorage\Manager as FileStorageManager;
use Espo\Core\ORM\EntityManager;
use Espo\Core\Utils\Metadata;
class Download implements EntryPoint
{
@@ -70,8 +68,8 @@ class Download implements EntryPoint
throw new BadRequest();
}
/** @var AttachmentEntity|null $attachment */
$attachment = $this->entityManager->getEntityById('Attachment', $id);
/** @var ?AttachmentEntity $attachment */
$attachment = $this->entityManager->getEntityById(AttachmentEntity::ENTITY_TYPE, $id);
if (!$attachment) {
throw new NotFoundSilent();
@@ -89,7 +87,7 @@ class Download implements EntryPoint
$outputFileName = str_replace("\"", "\\\"", $attachment->get('name'));
$type = $attachment->get('type');
$type = $attachment->getType();
$disposition = 'attachment';