use a stream to generate previews

 this way it also works for public shared galleries and with encryption enabled

cc @PVince81