I think this is why calling $stream->seek() still results in the full file content.
You could try creating a decorating the \Slim\Http\Stream instance with a class that implements Psr\Http\Message\StreamInterface and implement at minimum isSeekable(), rewind(), eof() and read(). The call to rewind() would then translate to a seek() call on the stream that is decorated.
I haven’t checked, but perhaps there is already a middleware solution for this. If so you don’t have to roll your own.
You’re right, I just added a condition around the $body->rewind();
In order to differentiate the stream from a [partial] file or a JSON response in body.