I want to perform directory Download. So I want to know what is the maximum storage size of List<Stream>
. Directory may contain more than 3000 files and I'm going to return list of files as stream in from API. So, is it a good idea to return an object of List<Stream>
?
I'm trying to get all existing files to be downloaded to be returned from an API to response
CodePudding user response:
A list's maximum capacity is going to be way way more than 3000, so: that's fine; it is a simple "number of elements" question, not a "sum of the size of each element" one. However, returning a large number of Stream
objects seems ... a: not ideal, and b: unlikely to work in many cases. Every stream needs to be closed correctly (typically: via using
), and having a list of streams seems like a good way to make that unreliable. If this is a remote API, then most serializers are likely to "nope" that outright - maybe returning an in-memory zip of the contents as a single stream would be better? If it is a local API, then maybe consider something that returns a mechanism to access the files individually; heck, even just returning the paths would seem preferable.