src/Valkyrja/HttpMessage/NativeUploadedFile.php
public function getStream(): Stream
    {
        // If the error status is not OK
        if (UPLOAD_ERR_OK !== $this->errorStatus) {
            // Throw a runtime exception as there's been an uploaded file error
            throw new RuntimeException(
                'Cannot retrieve stream due to upload error'
            );
        }

        // If the file has already been moved
        if ($this->moved) {
            // Throw a runtime exception as subsequent moves are not allowed
            // in PSR-7
            throw new RuntimeException(
                'Cannot retrieve stream after it has already been moved'
            );
        }

        // If the stream has been set
        if (null !== $this->stream) {
            // Return the stream
            return $this->stream;
        }

        // Set the stream as a new native stream
        $this->stream = new NativeStream($this->file);

        return $this->stream;
    }
public function getStream(): Stream
    {
        // If the error status is not OK
        if (UPLOAD_ERR_OK !== $this->errorStatus) {
            // Throw a runtime exception as there's been an uploaded file error
            throw new RuntimeException(
                'Cannot retrieve stream due to upload error'
            );
        }

        // If the file has already been moved
        if ($this->moved) {
            // Throw a runtime exception as subsequent moves are not allowed
            // in PSR-7
            throw new RuntimeException(
                'Cannot retrieve stream after it has already been moved'
            );
        }

        // If the stream has been set
        if (null !== $this->stream) {
            // Return the stream
            return $this->stream;
        }

        // Set the stream as a new native stream
        $this->stream = new NativeStream($this->file);

        return $this->stream;
    }
Retrieve a stream representing the uploaded file.

This method MUST return a StreamInterface instance, representing the
uploaded file. The purpose of this method is to allow utilizing native
PHP stream functionality to manipulate the file upload, such as
stream_copy_to_stream() (though the result will need to be decorated in
a native PHP stream wrapper to work with such functions).

If the moveTo() method has been called previously, this method MUST
raise an exception.

@throws \RuntimeException in cases when no stream is available or can
be created.
@throws \Valkyrja\HttpMessage\Exceptions\InvalidStream

@return \Valkyrja\HttpMessage\Stream Stream representation of the
uploaded file.