add limited support for attaching readstream, and related tests; use streaming for saveToFile function
better memory usage