diff --git a/application/Espo/Core/FileStorage/Manager.php b/application/Espo/Core/FileStorage/Manager.php index a9bb2aab74..283bf42d0a 100644 --- a/application/Espo/Core/FileStorage/Manager.php +++ b/application/Espo/Core/FileStorage/Manager.php @@ -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); } diff --git a/application/Espo/Core/FileStorage/Storages/AwsS3.php b/application/Espo/Core/FileStorage/Storages/AwsS3.php index a0c8045508..89144a6495 100644 --- a/application/Espo/Core/FileStorage/Storages/AwsS3.php +++ b/application/Espo/Core/FileStorage/Storages/AwsS3.php @@ -113,6 +113,8 @@ class AwsS3 implements Storage throw new RuntimeException("Could not open temp."); } + $stream->rewind(); + fwrite($resource, $stream->getContents()); rewind($resource); diff --git a/application/Espo/Core/FileStorage/Storages/EspoUploadDir.php b/application/Espo/Core/FileStorage/Storages/EspoUploadDir.php index a2cb697bdd..efaf0321e1 100644 --- a/application/Espo/Core/FileStorage/Storages/EspoUploadDir.php +++ b/application/Espo/Core/FileStorage/Storages/EspoUploadDir.php @@ -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);