I'm trying to download a zip file in spring boot. Using HttpServletResponse
output stream. We will be reading a file from local, zip it, inside StreamingResponseBody
and add it in the return statement of ResponseEntity.body(StreamingResponseBody)
. We require content length to show progress bar in UI. We can get zipEntry.getCompressedSize()
for the content length. But as soon as the zip file is written spring boot sending response headers to UI and I'll be getting content length only after I close zipoutputstream. Because of this I'm getting 0 as content length as a header in UI.
Can you please help me to properly add content length to response headers.
Thanks in advance.