feat: mail entity download
All checks were successful
Build Test / build (pull_request) Successful in 20s
JS Unit Tests / test (pull_request) Successful in 18s
PHP Unit Tests / test (pull_request) Successful in 40s

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-05-28 23:02:37 -04:00
parent 8d716e3c72
commit 812a6680a8
2 changed files with 51 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ namespace KTXF\Mail\Service;
use Generator;
use KTXF\Mail\Collection\CollectionBaseInterface;
use KTXF\Mail\Object\AddressInterface;
use KTXF\Resource\BinaryResource;
use KTXF\Resource\Delta\Delta;
use KTXF\Resource\Filter\IFilter;
use KTXF\Resource\Identifier\EntityIdentifierInterface;
@@ -262,4 +263,16 @@ interface ServiceBaseInterface extends ResourceServiceBaseInterface {
*/
public function entityFetchStream(EntityIdentifierInterface ...$identifiers): Generator;
/**
* Downloads a message or part of a message
*
* @since 2025.05.01
*
* @param EntityIdentifierInterface $target Message identifier
* @param array|null $part Optional part to download
*
* @return BinaryResource
*/
public function entityDownload(EntityIdentifierInterface $target, array|null $part): BinaryResource;
}

View File

@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace KTXF\Resource;
/**
* Carries file-like binary content metadata and a byte stream.
*/
final class BinaryResource
{
public function __construct(
private readonly string $filename,
private readonly string $mimeType,
private readonly \Generator $stream,
) {}
public function filename(): string
{
return $this->filename;
}
public function mimeType(): string
{
return $this->mimeType;
}
public function stream(): \Generator
{
return $this->stream;
}
}