List of usage examples for org.springframework.http MediaType IMAGE_JPEG_VALUE
String IMAGE_JPEG_VALUE
To view the source code for org.springframework.http MediaType IMAGE_JPEG_VALUE.
Click Source Link
From source file:com._8x8.presentation.controller.qrCodeController.java
@ResponseBody @RequestMapping(value = "qrCode/{qrInfo:.+}", method = RequestMethod.GET, produces = MediaType.IMAGE_JPEG_VALUE) public byte[] qrCode(@PathVariable("qrInfo") String qrInfo) { ByteArrayOutputStream in = _qrCodeService.getQRCodeBytesStream(qrInfo); return in.toByteArray(); }
From source file:com.greglturnquist.springagram.fileservice.mongodb.FileService.java
public void saveFile(InputStream input, String filename) { this.gridFsTemplate.delete(query(whereFilename().is(filename))); this.gridFsTemplate.store(input, filename, MediaType.IMAGE_JPEG_VALUE); }
From source file:com.trenako.web.images.ThumbnailatorServiceTests.java
@Test public void shouldCreateImages() throws Exception { final byte[] content = "file content".getBytes(); MultipartFile file = mockFile(content, MediaType.IMAGE_JPEG); UploadFile img = imgConverter.createImage(file, metadata()); assertNotNull(img.getContent());// w w w .j a va 2 s . c o m assertEquals(MediaType.IMAGE_JPEG_VALUE.toString(), img.getContentType()); }
From source file:bg.vitkinov.edu.services.ImageService.java
@RequestMapping(value = "/img", method = { RequestMethod.POST }, produces = { MediaType.IMAGE_PNG_VALUE, MediaType.IMAGE_GIF_VALUE, MediaType.IMAGE_JPEG_VALUE, MediaType.APPLICATION_OCTET_STREAM_VALUE }) public byte[] convertToInlineTextImage(@RequestHeader(value = "Accept") String acceptType, @RequestParam String text, @RequestParam(required = false, defaultValue = "false") String base64, @RequestParam(required = false, defaultValue = "Arial-14") String font, @RequestParam(required = false, defaultValue = "black") String foreColor, @RequestParam(required = false) String backColor) { logger.info(acceptType);//w ww. j a v a2s. c o m logger.info("Text: " + text); return convert(Boolean.valueOf(base64) ? new String(Base64.getDecoder().decode(text)) : text, new TextToGraphicsConverter(createGraphicsProperties(font, foreColor, backColor)), GraphicsType.value(acceptType)); }
From source file:com.epam.ta.reportportal.database.dao.UserRepositoryTest.java
@Test public void replaceUserTest() throws IOException { String username = RandomStringUtils.randomAlphabetic(5); User user = new User(); user.setLogin(username);/* w w w . j a v a 2s .co m*/ user.setEmail(username + "@epam.com"); user.setType(UserType.INTERNAL); userRepository.save(user); BinaryData binaryData = new BinaryData(MediaType.IMAGE_JPEG_VALUE, photoResource.getFile().length(), photoResource.getInputStream()); userRepository.replaceUserPhoto(user.getLogin(), binaryData); /* add one more data with such filename */ dataStorage.saveData(binaryData, photoFilename(username)); Assert.assertEquals("Incorrect count of files", 2, dataStorage.findByFilename(photoFilename(username)).size()); /* replace photo again */ userRepository.replaceUserPhoto(user.getLogin(), binaryData); /* make sure duplicates are removed */ Assert.assertEquals("Incorrect count of files", 1, dataStorage.findByFilename(photoFilename(username)).size()); }
From source file:fi.helsinki.opintoni.web.rest.publicapi.PublicImageResourceTest.java
@Test public void thatUserAvatarIsReturned() throws Exception { mockMvc.perform(get("/api/public/v1/images/avatar/987654321")).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.IMAGE_JPEG_VALUE)); }
From source file:fi.helsinki.opintoni.web.rest.publicapi.PublicImageResource.java
@RequestMapping(value = "/avatar/{oodiPersonId}", method = RequestMethod.GET, produces = MediaType.IMAGE_JPEG_VALUE) public ResponseEntity<BufferedImage> getUserAvatarByOodiPersonId( @PathVariable("oodiPersonId") String oodiPersonId) throws IOException { return ResponseEntity.ok().headers(headersWithContentType(MediaType.IMAGE_JPEG)) .body(userSettingsService.getUserAvatarImageByOodiPersonId(oodiPersonId)); }
From source file:fi.helsinki.opintoni.web.rest.publicapi.PublicImageResource.java
@RequestMapping(value = "/background/{oodiPersonId}", method = RequestMethod.GET, produces = MediaType.IMAGE_JPEG_VALUE) public ResponseEntity<BufferedImage> getUserBackgroundByOodiPersonId( @PathVariable("oodiPersonId") String oodiPersonId) throws IOException { return ResponseEntity.ok().headers(headersWithContentType(MediaType.IMAGE_JPEG)) .body(userSettingsService.getUserBackgroundImage(oodiPersonId)); }
From source file:org.messic.server.facade.controllers.rest.MusicInfoController.java
@ApiMethod(path = "/services/musicinfo/providericon?pluginName=xxxx", verb = ApiVerb.GET, description = "Get icon image of a certain musicinfo plugin", produces = { MediaType.IMAGE_JPEG_VALUE }) @ApiErrors(apierrors = { @ApiError(code = UnknownMessicRESTException.VALUE, description = "Unknown error"), @ApiError(code = NotAuthorizedMessicRESTException.VALUE, description = "Forbidden access"), @ApiError(code = NotFoundMessicRESTException.VALUE, description = "Plugin not found"), @ApiError(code = IOMessicRESTException.VALUE, description = "IO internal server error"), }) @RequestMapping(value = "/providericon", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK)// w w w . j ava2 s .co m @ResponseBody @ApiResponseObject public ResponseEntity<byte[]> getProviderIcon( @RequestParam(value = "pluginName", required = true) @ApiParam(name = "pluginName", description = "Name of the plugin to obtain information", paramType = ApiParamType.QUERY, required = true) String pluginName) throws UnknownMessicRESTException, NotAuthorizedMessicRESTException, NotFoundMessicRESTException, IOMessicRESTException { byte[] content = musicInfoAPI.getMusicInfoProviderIcon(pluginName); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.IMAGE_JPEG); return new ResponseEntity<byte[]>(content, headers, HttpStatus.OK); }
From source file:fi.helsinki.opintoni.web.rest.publicapi.PublicImageResourceTest.java
@Test public void thatBackgroundImageIsReturned() throws Exception { mockMvc.perform(get(DEFAULT_BACKGROUND_IMAGE_URL)).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.IMAGE_JPEG_VALUE)); }