Download attachments
This commit is contained in:
@ -3,9 +3,11 @@ namespace ProVM\Common\Service;
|
||||
|
||||
use Ddeboer\Imap\Message\AttachmentInterface;
|
||||
use Ddeboer\Imap\MessageInterface;
|
||||
use Nyholm\Psr7\Stream;
|
||||
use ProVM\Common\Exception\Message\NoAttachments;
|
||||
use ProVM\Emails\Model\Message;
|
||||
use ProVM\Emails\Repository\Attachment;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Safe\Exceptions\FilesystemException;
|
||||
|
||||
@ -84,6 +86,22 @@ class Attachments extends Base
|
||||
$remote_message = $this->getMessages()->getRemoteMessage($message->getUID());
|
||||
return $this->getRemoteService()->get($remote_message, $relative_filename);
|
||||
}
|
||||
public function getFile(int $attachment_id): string
|
||||
{
|
||||
$attachment = $this->getRepository()->fetchById($attachment_id);
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
$this->getFolder(),
|
||||
$attachment->getFullFilename()
|
||||
]);
|
||||
if ($attachment->isDecrypted()) {
|
||||
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||
$this->getFolder(),
|
||||
'decrypted',
|
||||
$attachment->getFullFilename()
|
||||
]);
|
||||
}
|
||||
return \Safe\file_get_contents($filename);
|
||||
}
|
||||
|
||||
public function getAll(): array
|
||||
{
|
||||
|
Reference in New Issue
Block a user