In a servlet, I want to read an EML from my database and serving it to the client with a “download file” UI. When I specify the Content-Length header, the download takes minutes to start. When I don’t, everything works well, but I do want to set that header 🙂 What am I missing?
// part is javax.mail.Part
response.setHeader("Content-Disposition", "attachment" + filename);
response.setContentType(mime);
response.setContentLength(part.getSize()); // This line causes the problem
IOUtils.copy(part.getInputStream(), out);
Just a guess – maybe the file has to be fetched from DB to get its size ? Save the size to separate column and serve the value from there. Also working with the file-in-DB through java.sql.Blob should work.
Unfortunately in your sample there is no info where you take the part object from.