feat: blobs fetch
PHP Unit Tests / test (pull_request) Failing after 11m59s
JS Unit Tests / test (pull_request) Failing after 12m1s
Build Test / test (pull_request) Failing after 12m3s

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-06-18 19:38:11 -04:00
parent 105f69c3a5
commit bb349646c3
4 changed files with 98 additions and 1 deletions
+39
View File
@@ -162,6 +162,7 @@ class DefaultController extends ControllerAbstract {
'entity.copy' => throw new InvalidArgumentException('Operation not implemented: ' . $operation),
'entity.submit' => $this->entitySubmit($tenantId, $userId, $data),
'entity.download' => $this->entityDownload($tenantId, $userId, $data),
'entity.blobs' => $this->entityBlobs($tenantId, $userId, $data),
default => throw new InvalidArgumentException(self::ERR_INVALID_OPERATION . $operation)
};
@@ -895,5 +896,43 @@ class DefaultController extends ControllerAbstract {
'Cache-Control' => 'no-store',
]);
}
private function entityBlobs(string $tenantId, string $userId, array $data): mixed {
if (!isset($data['target'])) {
throw new InvalidArgumentException(self::ERR_MISSING_TARGET);
}
if (!is_string($data['target'])) {
throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER);
}
if (!isset($data['parts']) || !is_array($data['parts']) || $data['parts'] === []) {
throw new InvalidArgumentException('At least one part selector is required');
}
$target = ResourceIdentifier::fromString($data['target']);
$results = [];
foreach ($data['parts'] as $part) {
if (!is_array($part)) {
throw new InvalidArgumentException('Invalid part selector');
}
$resource = $this->mailManager->entityDownload($tenantId, $userId, $target, $part);
$bytes = '';
foreach ($resource->stream() as $chunk) {
$bytes .= $chunk;
}
$results[] = [
'source' => $data['target'],
'part' => $part,
'mime' => $resource->mimeType(),
'filename' => $resource->filename(),
'bytes' => base64_encode($bytes),
];
}
return $results;
}
}