org.apache.log4j.lf5.util.StreamUtils Java Examples
The following examples show how to use
org.apache.log4j.lf5.util.StreamUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UpAndDownloadImageFileAsByteArray.java From projectforge-webapp with GNU General Public License v3.0 | 6 votes |
protected void doPost(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { log.debug("Start doPost"); try { // Inputstream final InputStream is = request.getInputStream(); final byte[] buffer = StreamUtils.getBytes(is); String filename; String croppedname; if (request.getParameter("croppedname") != null) { croppedname = request.getParameter("croppedname"); } else { croppedname = "cropped"; } if ((request.getParameter("filename") != null) && (request.getParameter("filetype") != null)) { filename = croppedname + request.getParameter("filename") + "." + request.getParameter("filetype"); } else { filename = "image.png"; } log.info("Filename: " + filename); ResponseUtils.streamToOut(filename, buffer, response, request.getSession().getServletContext(), true); } catch (Exception ex) { log.warn("Failure reading the request"); log.warn(ex.getMessage(), ex); } }