Skip to content

Commit

Permalink
Fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
k-tamura committed Mar 3, 2017
1 parent f2fae52 commit 81ee6c6
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Locale;

import javax.imageio.ImageIO;

import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
Expand All @@ -27,12 +28,12 @@
@SuppressWarnings("serial")
@WebServlet(urlPatterns = { "/urupload" })
// 2MB, 10MB, 50MB
// @MultipartConfig(fileSizeThreshold = 1024 * 1024 * 2, maxFileSize = 1024 * 1024 * 10, maxRequestSize = 1024 * 1024 *
// 50)
// @MultipartConfig(fileSizeThreshold = 1024 * 1024 * 2, maxFileSize = 1024 * 1024 * 10,
// maxRequestSize = 1024 * 1024 * 50)
@MultipartConfig
public class UnrestrictedUploadServlet extends HttpServlet {

private static Logger log = LoggerFactory.getLogger(DBConnectionLeakServlet.class);
private static Logger log = LoggerFactory.getLogger(UnrestrictedUploadServlet.class);

// Name of the directory where uploaded files is saved
private static final String SAVE_DIR = "uploadFiles";
Expand Down Expand Up @@ -63,13 +64,14 @@ protected void doPost(HttpServletRequest req, HttpServletResponse res) throws Se
// Get absolute path of the web application
String appPath = req.getServletContext().getRealPath("");

// Create directory to save uploaded file if it does not exists
// Create a directory to save the uploaded file if it does not exists
String savePath = appPath + File.separator + SAVE_DIR;
File fileSaveDir = new File(savePath);
if (!fileSaveDir.exists()) {
fileSaveDir.mkdir();
}

// Save the file
OutputStream out = null;
InputStream in = null;
final Part filePart = req.getPart("file");
Expand All @@ -88,7 +90,7 @@ protected void doPost(HttpServletRequest req, HttpServletResponse res) throws Se

boolean isConverted = true;
try {
// Revere color of the upload image
// Reverse the color of the upload image
revereColor(new File(savePath + File.separator + fileName).getAbsolutePath());
} catch (Exception e) {
// Log and ignore the exception
Expand Down Expand Up @@ -119,6 +121,7 @@ protected void doPost(HttpServletRequest req, HttpServletResponse res) throws Se
}
}

// Get file name from content-disposition filename
private String getFileName(final Part part) {
for (String content : part.getHeader("content-disposition").split(";")) {
if (content.trim().startsWith("filename")) {
Expand All @@ -128,7 +131,7 @@ private String getFileName(final Part part) {
return null;
}

// Revere color of the image file
// Reverse the color of the image file
private void revereColor(String fileName) throws IOException {
BufferedImage image = ImageIO.read(new File(fileName));
WritableRaster raster = image.getRaster();
Expand Down

0 comments on commit 81ee6c6

Please sign in to comment.