file storage fixes

This commit is contained in:
Yuri Kuznetsov
2022-07-12 14:00:09 +03:00
parent 14d4647b5a
commit e5589d8b7d
3 changed files with 7 additions and 2 deletions

View File

@@ -35,7 +35,7 @@ use Psr\Http\Message\StreamInterface;
use RuntimeException;
use function GuzzleHttp\Psr7\stream_for;
use GuzzleHttp\Psr7\Utils;
/**
* An access point for file storing and fetching. Files are represented as Attachment entities.
@@ -119,7 +119,7 @@ class Manager
{
$implementation = $this->getImplementation($attachment);
$stream = stream_for($contents);
$stream = Utils::streamFor($contents);
$implementation->putStream(self::wrapAttachmentEntity($attachment), $stream);
}

View File

@@ -113,6 +113,8 @@ class AwsS3 implements Storage
throw new RuntimeException("Could not open temp.");
}
$stream->rewind();
fwrite($resource, $stream->getContents());
rewind($resource);

View File

@@ -99,6 +99,9 @@ class EspoUploadDir implements Storage, Local
{
$filePath = $this->getFilePath($attachment);
$stream->rewind();
// @todo Use a resource to write a file (add a method to the file manager).
$contents = $stream->getContents();
$result = $this->fileManager->putContents($filePath, $contents);