Example usage for org.springframework.http MediaType IMAGE_PNG_VALUE

List of usage examples for org.springframework.http MediaType IMAGE_PNG_VALUE

Introduction

In this page you can find the example usage for org.springframework.http MediaType IMAGE_PNG_VALUE.

Prototype

String IMAGE_PNG_VALUE

To view the source code for org.springframework.http MediaType IMAGE_PNG_VALUE.

Click Source Link

Document

A String equivalent of MediaType#IMAGE_PNG .

Usage

From source file:org.leandreck.endpoints.case1.NoJson.java

@RequestMapping(value = "/int", method = GET, produces = MediaType.IMAGE_PNG_VALUE)
public @ResponseBody int getInt() {
    return 1;
}

From source file:org.leandreck.endpoints.case1.NoJsonMultiple.java

@RequestMapping(value = "/int", method = GET, produces = { MediaType.IMAGE_PNG_VALUE,
        MediaType.APPLICATION_ATOM_XML_VALUE, MediaType.APPLICATION_OCTET_STREAM_VALUE })
public @ResponseBody int getInt() {
    return 1;/*from w w  w  .  ja v a 2s  . co m*/
}

From source file:com.github.spring.example.SpringExampleApp.java

@RequestMapping(value = QRCODE_ENDPOINT, method = RequestMethod.GET, produces = MediaType.IMAGE_PNG_VALUE)
@CacheControl(maxAge = 3600, policy = { CachePolicy.PUBLIC })
public ListenableFuture<byte[]> getQRCode(@RequestParam(value = "text", required = true) String text) {
    try {/*from  w  ww  . j a v a  2  s .com*/
        return imageService.generateQRCodeAsync(text, 256, 256);
    } catch (Exception ex) {
        throw new InternalServerError("Error while generating QR code image.", ex);
    }
}

From source file:org.moserp.product.rest.ProductControllerTest.java

@Test
public void testProductEan() {
    Response imageResponse = given().when().get("/products/" + product.getId() + "/ean");
    assertNotNull("response", imageResponse);
    imageResponse.then().statusCode(HttpStatus.OK.value()).and().contentType(MediaType.IMAGE_PNG_VALUE);
}

From source file:com.nebhale.gpxconverter.ApplicationController.java

@RequestMapping(method = RequestMethod.POST, value = "", consumes = MediaType.APPLICATION_XML_VALUE, produces = MediaType.IMAGE_PNG_VALUE)
ResponseEntity<Void> image(@RequestBody DOMSource source,
        @RequestParam(defaultValue = "roadmap") String maptype,
        @RequestParam(defaultValue = "500") Integer width, @RequestParam(defaultValue = "500") Integer height) {
    this.logger.info("Rendering existing GPX file");
    List<Point> points = this.parser.parsePoints((Document) source.getNode());

    HttpHeaders headers = new HttpHeaders();
    headers.setLocation(this.mapBuilder.build(points, maptype, width, height));

    return new ResponseEntity<>(headers, HttpStatus.SEE_OTHER);
}

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);//from   w w  w.j  a  v  a2s.com
    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:org.leandreck.endpoints.examples.SecondTypeScriptEndpoint.java

@TypeScriptIgnore
@RequestMapping(value = "/photos/{id}", method = GET, produces = MediaType.IMAGE_PNG_VALUE)
public ResponseEntity<InputStreamResource> getPhoto(@PathVariable Long id) {
    return ResponseEntity.ok().contentLength(0).contentType(IMAGE_PNG)
            .body(new InputStreamResource(new ByteArrayInputStream("No Content".getBytes())));
}

From source file:nu.yona.server.subscriptions.rest.UserPhotoController.java

@RequestMapping(value = "/userPhotos/{userPhotoId}", method = RequestMethod.GET, produces = {
        MediaType.IMAGE_PNG_VALUE })
@ResponseBody//from ww w .  jav  a 2 s  .  c  om
public ResponseEntity<byte[]> getUserPhoto(@PathVariable UUID userPhotoId) {
    return new ResponseEntity<>(userPhotoService.getUserPhoto(userPhotoId).getPngBytes(), HttpStatus.OK);
}

From source file:bg.vitkinov.edu.services.JokeService.java

@RequestMapping(value = "/jokeImage/{id}", method = RequestMethod.GET, produces = { MediaType.IMAGE_PNG_VALUE })
public ResponseEntity<byte[]> getJokeImage(@PathVariable Long id,
        @RequestHeader(value = "Accept") String acceptType,
        @RequestParam(required = false, defaultValue = "Arial-14") String font,
        @RequestParam(required = false, defaultValue = "black") String foreColor,
        @RequestParam(required = false) String backColor) {
    Joke joke = jokeRepository.findOne(id);
    ServiceInstance instance = loadBalancerClient.choose("image-service");
    if (instance == null)
        return null;
    /*/*w  w w  . ja  v a2 s .c om*/
    MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
    params.set("text", Base64.getEncoder().encodeToString(joke.getContent().getBytes()));
      params.set("Accept", acceptType);
      params.set("base64", "true");
      params.set("font", font);
      params.set("foreColor", foreColor);
      params.set("foreColor", foreColor);
      params.set("backColor", backColor);
      */
    HttpHeaders params = new HttpHeaders();
    MediaType requestAcceptType = acceptType == null || "".equals(acceptType) ? MediaType.IMAGE_PNG
            : MediaType.parseMediaType(acceptType);
    params.setAccept(Arrays.asList(requestAcceptType));
    params.add("text", Base64.getEncoder().encodeToString(joke.getContent().getBytes()));
    params.add("base64", "true");
    params.add("font", font);
    params.add("foreColor", foreColor);
    params.add("backColor", backColor);

    //        URI url = URI.create(String.format("%s/img", instance.getUri().toString()))
    URI url = instance.getUri().resolve("/img");
    HttpEntity<byte[]> entity = new HttpEntity<byte[]>(null, params);
    return restTemplate.exchange(url.toString(), HttpMethod.POST, entity, byte[].class);
}

From source file:de.petendi.ethereum.secure.proxy.controller.WelcomeController.java

@ResponseBody
@RequestMapping(value = "qr.png", method = RequestMethod.GET, produces = MediaType.IMAGE_PNG_VALUE)
public byte[] getQrCode() throws IOException {
    return qrcode;
}