I'm new to Java, and very new to Spring, Rest, and IO Streams, so apologies.
What I need to do is construct a zip file using ZipOutputStream, and then send that file to a REST endpoint as multipart file data.
I've been told that it should be possible to do this without holding the entire zip file in memory (it could be very large), by doing some clever streaming.
Something like creating a stream, then passing it to the rest template, and then writing the zip to the stream x bytes at a time, and the rest template will automatically stream each new block of bytes over the HTTP request as they get written without having to assemble the entire file on disk or in memory first (or maybe the stream has some kind of callback lambda that is invoked by the rest template trying to read the stream, so I can append more data to it)
Is that possible?
I've found similar posts, but none that help me understand how to do this, if it's at all possible. POST InputStream RestTemplate How to forward large files with RestTemplate?