Fixing Incident: #18926 for all getSize()

This commit is contained in:
francesco 2020-03-27 11:44:41 +01:00
parent f182f5e6ca
commit 10dd659d40
1 changed files with 17 additions and 2 deletions

View File

@ -237,7 +237,15 @@ public class DownloadServlet extends HttpServlet{
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
resp.setContentType(mimeType);
resp = setContentLength(resp, pdfFile.getSize());
//Fixing Incident: 18926, replacing pdfFile.getSize() with ItemStreamDescriptor.getSize()
if(descr.getSize()!=null && descr.getSize()>0) {
resp = setContentLength(resp, descr.getSize());
}
logger.info("The "+workspaceFileItem.getFileItemType()+" size is: "+descr.getSize());
//resp = setContentLength(resp, pdfFile.getSize());
InputStream is = descr.getStream();
OutputStream out = resp.getOutputStream();
IOUtils.copy(is, out);
@ -263,7 +271,14 @@ public class DownloadServlet extends HttpServlet{
String contentDisposition = viewContent?"inline":"attachment";
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
resp.setContentType(mimeType);
resp = setContentLength(resp, imageFile.getSize());
//Fixing Incident: 18926, replacing imageFile.getSize() with ItemStreamDescriptor.getSize()
if(descr.getSize()!=null && descr.getSize()>0) {
resp = setContentLength(resp, descr.getSize());
}
logger.info("The "+workspaceFileItem.getFileItemType()+" size is: "+descr.getSize());
//resp = setContentLength(resp, imageFile.getSize());
InputStream is = descr.getStream();
OutputStream out = resp.getOutputStream();