diff options
Diffstat (limited to 'library/SSRS/Report')
-rw-r--r-- | library/SSRS/Report/CachedStreamResource.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/library/SSRS/Report/CachedStreamResource.php b/library/SSRS/Report/CachedStreamResource.php new file mode 100644 index 0000000..08e9dbb --- /dev/null +++ b/library/SSRS/Report/CachedStreamResource.php @@ -0,0 +1,43 @@ +<?php + +namespace SSRS\Report; + +use \SSRS\Object\RenderStream; + +class CachedStreamResource { + + public $streamId; + public $filePath; + + public function __construct($streamId, $filePath) { + $this->streamId = $streamId; + $this->filePath = $filePath; + } + + public function read() { + $data = file_get_contents($this->filePath); + $parts = explode("\n", $data, 2); + + $stream = new RenderStream(); + $stream->MimeType = $parts[0]; + $stream->Result = $parts[1]; + + return $stream; + } + + public function store(RenderStream $renderStream) { + $data = trim($renderStream->MimeType) . "\n"; + $data .= $renderStream->Result; + + file_put_contents($this->filePath, $data); + return $this; + } + + public function send() { + $stream = $this->read(); + + header('Content-Type: ' . $stream->MimeType); + echo $stream->Result; + } + +} |