argh, i see the problem now, yes. we rewind before we return it, but doctrine does not know that. what we could do is make the file class have a doctrine listener on prePersist/preUpdate that rewinds the stream if its not null. that is the only sane way imho. but then, the file is in phpcr-odm, so we might do it in the media bundle file for now, but should fix this in phpcr-odm too. rewinding twice does not hurt (if we make the method overwrite each other, it should hopefully only be executed once)

http://docs.doctrine-project.org/projects/doctrine-phpcr-odm/en/latest/reference/events.html#lifecycle-callbacks

copying the stream sounds like performance nightmare.