objectPrefix = $parameters['objectPrefix'] . 'preview:'; } } public function writePreview(Preview $preview, $stream): false|int { if (!is_resource($stream)) { $fh = fopen('php://temp', 'w+'); fwrite($fh, $stream); rewind($fh); $stream = $fh; } $size = 0; $countStream = CountWrapper::wrap($stream, function (int $writtenSize) use (&$size): void { $size = $writtenSize; }); $this->objectStore->writeObject($this->constructUrn($preview), $countStream); return $size; } public function readPreview(Preview $preview) { return $this->objectStore->readObject($this->constructUrn($preview)); } public function deletePreview(Preview $preview) { return $this->objectStore->deleteObject($this->constructUrn($preview)); } private function constructUrn(Preview $preview): string { return $this->objectPrefix . $preview->getId(); } }