private void serveFile(File file) throws IOException { FileInputStream fis = new FileInputStream(file); try { setVerificationHeadersForGet(response, file); setFileNameHeaders(response, file); if (!file.exists()) { // Potential race where the file was deleted while we were in the // process of setting headers! throw new FileNotFoundException(file.toString()); // It's possible the file could be deleted after this point, but // we've already opened the 'fis' stream. // It's also possible length could change, but this would be // detected by the client side as an inaccurate length header. } // send file DataTransferThrottler throttler = parsedParams.isBootstrapStandby ? getThrottlerForBootstrapStandby(conf) : getThrottler(conf); TransferFsImage.copyFileToStream(response.getOutputStream(), file, fis, throttler); } finally { IOUtils.closeStream(fis); } } });
ImageServlet.setFileNameHeaders(response, editFile); editFileIn = new FileInputStream(editFile);
private void serveFile(File file) throws IOException { FileInputStream fis = new FileInputStream(file); try { setVerificationHeadersForGet(response, file); setFileNameHeaders(response, file); if (!file.exists()) { // Potential race where the file was deleted while we were in the // process of setting headers! throw new FileNotFoundException(file.toString()); // It's possible the file could be deleted after this point, but // we've already opened the 'fis' stream. // It's also possible length could change, but this would be // detected by the client side as an inaccurate length header. } // send file TransferFsImage.copyFileToStream(response.getOutputStream(), file, fis, getThrottler(conf)); } finally { IOUtils.closeStream(fis); } } });
private void serveFile(File file) throws IOException { FileInputStream fis = new FileInputStream(file); try { setVerificationHeadersForGet(response, file); setFileNameHeaders(response, file); if (!file.exists()) { // Potential race where the file was deleted while we were in the // process of setting headers! throw new FileNotFoundException(file.toString()); // It's possible the file could be deleted after this point, but // we've already opened the 'fis' stream. // It's also possible length could change, but this would be // detected by the client side as an inaccurate length header. } // send file TransferFsImage.copyFileToStream(response.getOutputStream(), file, fis, getThrottler(conf)); } finally { IOUtils.closeStream(fis); } } });
ImageServlet.setFileNameHeaders(response, editFile); editFileIn = new FileInputStream(editFile);
ImageServlet.setFileNameHeaders(response, editFile); editFileIn = new FileInputStream(editFile);