ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
MemoryStreamToTempFileStream.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Filesystem\Util;
22
25
29trait MemoryStreamToTempFileStream
30{
31 protected function maybeSafeToTempStream(FileStream $stream): FileStream
32 {
33 if ($stream->getMetadata()['uri'] === 'php://memory') {
34 // save stream to temp file
35 $tmp = tmpfile();
36 fwrite($tmp, (string) $stream);
37 $temp_stream = Streams::ofResource($tmp);
38 $temp_stream->rewind();
39
40 return $temp_stream;
41 }
42 return $stream;
43 }
44}
Stream factory which enables the user to create streams without the knowledge of the concrete class.
Definition: Streams.php:32
static ofResource($resource)
Wraps an already created resource with the stream abstraction.
Definition: Streams.php:64
The base interface for all filesystem streams.
Definition: FileStream.php:32
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...