@Test public void testGetMediaTypeFromImageNameJpg() { String imageName = "image1.jpg"; ImageWS instance = new ImageWS(); MediaType expResult = MediaType.IMAGE_JPEG; MediaType result = instance.getMediaTypeFromImageName(imageName); assertEquals(expResult, result); }
MediaType getMediaTypeFromImageName(String imageName) { MediaType mediaType = MediaType.APPLICATION_OCTET_STREAM; String fileExtension = FilenameUtils.getExtension(imageName).toLowerCase(); switch (fileExtension) { case "jpeg": case "jpg": mediaType = MediaType.IMAGE_JPEG; break; case "png": mediaType = MediaType.IMAGE_PNG; break; case "gif": mediaType = MediaType.IMAGE_GIF; break; } return mediaType; }
ImageWS { MediaType getMediaTypeFromImageName(String imageName) { MediaType mediaType = MediaType.APPLICATION_OCTET_STREAM; String fileExtension = FilenameUtils.getExtension(imageName).toLowerCase(); switch (fileExtension) { case "jpeg": case "jpg": mediaType = MediaType.IMAGE_JPEG; break; case "png": mediaType = MediaType.IMAGE_PNG; break; case "gif": mediaType = MediaType.IMAGE_GIF; break; } return mediaType; } }
ImageWS { MediaType getMediaTypeFromImageName(String imageName) { MediaType mediaType = MediaType.APPLICATION_OCTET_STREAM; String fileExtension = FilenameUtils.getExtension(imageName).toLowerCase(); switch (fileExtension) { case "jpeg": case "jpg": mediaType = MediaType.IMAGE_JPEG; break; case "png": mediaType = MediaType.IMAGE_PNG; break; case "gif": mediaType = MediaType.IMAGE_GIF; break; } return mediaType; }  }
ImageWS { MediaType getMediaTypeFromImageName(String imageName) { MediaType mediaType = MediaType.APPLICATION_OCTET_STREAM; String fileExtension = FilenameUtils.getExtension(imageName).toLowerCase(); switch (fileExtension) { case "jpeg": case "jpg": mediaType = MediaType.IMAGE_JPEG; break; case "png": mediaType = MediaType.IMAGE_PNG; break; case "gif": mediaType = MediaType.IMAGE_GIF; break; } return mediaType; }  @RequestMapping(value = "/api/images/**", method = RequestMethod.GET) @ResponseBody ResponseEntity getImage(HttpServletRequest httpServletRequest); @RequestMapping(value = "/api/images/**", method = RequestMethod.PUT) @ResponseBody void uploadImage(@RequestBody byte[] imageContent, HttpServletRequest httpServletRequest); }
ImageWS { MediaType getMediaTypeFromImageName(String imageName) { MediaType mediaType = MediaType.APPLICATION_OCTET_STREAM; String fileExtension = FilenameUtils.getExtension(imageName).toLowerCase(); switch (fileExtension) { case "jpeg": case "jpg": mediaType = MediaType.IMAGE_JPEG; break; case "png": mediaType = MediaType.IMAGE_PNG; break; case "gif": mediaType = MediaType.IMAGE_GIF; break; } return mediaType; }  @RequestMapping(value = "/api/images/**", method = RequestMethod.GET) @ResponseBody ResponseEntity getImage(HttpServletRequest httpServletRequest); @RequestMapping(value = "/api/images/**", method = RequestMethod.PUT) @ResponseBody void uploadImage(@RequestBody byte[] imageContent, HttpServletRequest httpServletRequest);  }