List of usage examples for org.springframework.http MediaType IMAGE_JPEG
MediaType IMAGE_JPEG
To view the source code for org.springframework.http MediaType IMAGE_JPEG.
Click Source Link
From source file:fi.helsinki.opintoni.web.rest.publicapi.PublicImageResource.java
@RequestMapping(value = "/backgrounds/{fileName:.+}", method = RequestMethod.GET, produces = MediaType.IMAGE_JPEG_VALUE) public ResponseEntity<BufferedImage> serve(@PathVariable String fileName) throws IOException { return ResponseEntity.ok().headers(headersWithContentType(MediaType.IMAGE_JPEG)) .body(backgroundImageService.getDefaultBackgroundImage(fileName)); }
From source file:se.omegapoint.facepalm.client.controllers.ImageController.java
@RequestMapping(value = "/img/{id}") public ResponseEntity<byte[]> image(final @PathVariable("id") String id) { final Image image = imageAdapter.fetchImage(Long.valueOf(id)); return ResponseEntity.ok().contentType(MediaType.IMAGE_JPEG).body(image.data); }
From source file:com.example.securelogin.app.account.AccountController.java
@RequestMapping(value = "/image") @ResponseBody/*from w ww.j a va 2 s. c o m*/ public ResponseEntity<byte[]> showImage(@AuthenticationPrincipal LoggedInUser userDetails) throws IOException { AccountImage userImage = accountSharedService.getImage(userDetails.getUsername()); HttpHeaders headers = new HttpHeaders(); if (userImage.getExtension().equalsIgnoreCase("png")) { headers.setContentType(MediaType.IMAGE_PNG); } else if (userImage.getExtension().equalsIgnoreCase("gif")) { headers.setContentType(MediaType.IMAGE_GIF); } else if (userImage.getExtension().equalsIgnoreCase("jpg")) { headers.setContentType(MediaType.IMAGE_JPEG); } return new ResponseEntity<byte[]>(IOUtils.toByteArray(userImage.getBody()), headers, HttpStatus.OK); }
From source file:com.greglturnquist.springagram.fileservice.s3.ApplicationController.java
@RequestMapping(method = RequestMethod.GET, value = "/files/{filename}") public ResponseEntity<?> getFile(@PathVariable String filename) throws IOException { Resource file = this.fileService.findOne(filename); try {/*ww w .j a v a2s . c o m*/ return ResponseEntity.ok().contentLength(file.contentLength()).contentType(MediaType.IMAGE_JPEG) .body(new InputStreamResource(file.getInputStream())); } catch (IOException e) { return ResponseEntity.badRequest().body("Couldn't process the request"); } }
From source file:com.trenako.web.images.WebImageServiceTests.java
private UploadFile uploadFile(String imgSlug) { return new UploadFile(new ByteArrayInputStream(new byte[] {}), MediaType.IMAGE_JPEG.toString(), "image.jpg", map("slug", imgSlug)); }
From source file:gr.cti.android.experimentation.Application.java
@Bean public EmbeddedServletContainerCustomizer servletContainerCustomizer() { return servletContainer -> ((TomcatEmbeddedServletContainerFactory) servletContainer) .addConnectorCustomizers((TomcatConnectorCustomizer) connector -> { AbstractHttp11Protocol httpProtocol = (AbstractHttp11Protocol) connector.getProtocolHandler(); httpProtocol.setCompression("on"); httpProtocol.setCompressionMinSize(256); String mimeTypes = httpProtocol.getCompressableMimeTypes(); String mimeTypesWithJson = mimeTypes + "," + MediaType.APPLICATION_JSON_VALUE + "," + MediaType.IMAGE_PNG + "," + MediaType.IMAGE_GIF + "," + MediaType.IMAGE_JPEG + "," + "application/javascript" + "," + "text/css"; httpProtocol.setCompressableMimeTypes(mimeTypesWithJson); });//from ww w . j ava 2 s .co m }
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 })// w w w. j a v a 2 s . c o m @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) @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:com.trenako.web.images.WebImageServiceTests.java
private MultipartFile multipartFile() { MultipartFile mf = new MockMultipartFile("upload", "upload.jpg", MediaType.IMAGE_JPEG.toString(), new byte[] {}); return mf;//from w w w . j a v a 2s. c o m }
From source file:doge.controller.UsersRestController.java
@RequestMapping(method = RequestMethod.GET, value = "{userId}/doge/{dogeId}", produces = MediaType.IMAGE_JPEG_VALUE) @ResponseStatus(HttpStatus.OK)// w w w . jav a 2 s . c om public Resource getDogePhoto(@PathVariable String userId, @PathVariable String dogeId) throws IOException { User user = this.userRepository.findOne(userId); Photo photo = this.dogeService.getDogePhoto(user, dogeId); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.IMAGE_JPEG); return new PhotoResource(photo); }
From source file:org.openschedule.api.impl.AbstractOpenSchedulApiBinding.java
/** * Returns a {@link ByteArrayHttpMessageConverter} to be used by the internal {@link RestTemplate} when consuming image or other binary resources. * By default, the message converter supports "image/jpeg", "image/gif", and "image/png" media types. * Override to customize the message converter (for example, to set supported media types). * To remove/replace this or any of the other message converters that are registered by default, override the getMessageConverters() method instead. *///from ww w. jav a 2 s . c om protected ByteArrayHttpMessageConverter getByteArrayMessageConverter() { ByteArrayHttpMessageConverter converter = new ByteArrayHttpMessageConverter(); converter.setSupportedMediaTypes( Arrays.asList(MediaType.IMAGE_JPEG, MediaType.IMAGE_GIF, MediaType.IMAGE_PNG)); return converter; }