I have a Rest service with the following method:
@RequestMapping(value = "/usuario/{login}", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<InputStreamResource> usuario(@PathVariable("login") String login, HttpServletRequest request) {
User user = userService.buscarPorNickname(login);
InputStream is = null;
if (user != null) {
try {
is = new FileInputStream(user.getPicture().getCaminho());
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (is == null) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
} else {
return ResponseEntity.ok().contentType(MediaType.IMAGE_PNG).body(new InputStreamResource(is));
}
}
When the user name has a period, the server understands it as a regular expression and returns me an empty file. How to get around this?