I have a GET REST API which accepts empno in request and returns the document in response. Right now we are passing the response as ResponseEntity. But when the client hits the URL then this documents gets downloaded from my API call. Below is my sample code:
public class ViewDocController {
@RequestMapping(value = "/{empno}", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<byte[]> viewDoc(@PathVariable(value = "empno") String empno)
throws ServletException, IOException {
return baseBiz.viewDoc(documentRequestBody);
}
}
But we want that instead of downloading, the file should open in the browser when we hit on the API URL. For example, if in my api url is: http://localhost:8080/rest/services/viewDoc/12345 then on hitting this on explorer, the file should open on the page.
Please suggest any way to do this