Skip to content

Instantly share code, notes, and snippets.

@joshlong
Last active December 14, 2015 22:09
Show Gist options
  • Select an option

  • Save joshlong/5156263 to your computer and use it in GitHub Desktop.

Select an option

Save joshlong/5156263 to your computer and use it in GitHub Desktop.
reading a user's profile photo
@RequestMapping(value = USER_COLLECTION_ENTRY_PHOTO_URL, method = RequestMethod.GET)
public ResponseEntity<byte[]> renderMedia(@PathVariable("userId") Long userId) throws Throwable {
InputStream is = userService.readUserProfilePhoto(userId);
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.IMAGE_JPEG);
byte buffer[] = IOUtils.toByteArray(is);
return new ResponseEntity<byte[]>(buffer, httpHeaders, HttpStatus.OK);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment