śr., 27 mar 2024 o 02:01 Mahabir Gupta <mahabir...@gmail.com> napisał(a): > > Dear Lukasz, > > Uploaded files are ok (access them on the server side once they have been > uploaded). The MD5 for the uploaded file to the server and the downloaded > file from the server is different. There is a decrease in the number of kb > when the file is downloaded. The MD5 changed when it passed through the > following code. > > ServletOutputStream out = null; > FileInputStream fi = null; > try { > out = response.getOutputStream(); > fi = new FileInputStream(f); > byte[] buffer = new byte[(int)f.length]; // Set the buffer size to > 4KB or any suitable size > > int bytesRead; > while ((bytesRead = fi.read(buffer)) != -1) { > out.write(buffer, 0, bytesRead); > } > } catch (FileNotFoundException e) { > e.printStackTrace(); > logger.info("File not found error" + filename); > logger.error(e.getMessage()); > } catch (IOException e) { > logger.info("Error in reading file:" + filename); > } finally { > if (out != null) safeClose(out); > if (fi != null) safeClose(fi); > }
This code isn't related to Struts and as far I see you are missing .flush() operation https://github.com/apache/struts/blob/master/core/src/main/java/org/apache/struts2/result/StreamResult.java#L282 Cheers Lukasz --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org