@GET
  @Path("/file")
  @Produces(MediaType.APPLICATION_JSON)
  public Response previewFile(@QueryParam("path") String path, @QueryParam("start") int start, @QueryParam("end") int end) {
    LOG.info("previewing file {}, from start {}, till end {}", path, start, end);
    try {
      HdfsApi api = getApi();
      FileStatus status = api.getFileStatus(path);

      CompressionCodec codec = compressionCodecFactory.getCodec(status.getPath());

      // check if we have a compression codec we need to use
      InputStream stream = (codec != null) ? codec.createInputStream(api.open(path)) : api.open(path);

      int length = end - start;
      byte[] bytes = new byte[length];

      if (start != 0) IOUtils.skip(stream, start);
      int readBytes = IOUtils.read(stream, bytes);
      boolean isFileEnd = false;

      if (readBytes < length) isFileEnd = true;

      JSONObject response = new JSONObject();
      response.put("data", new String(bytes));
      response.put("readbytes", readBytes);
      response.put("isFileEnd", isFileEnd);

      return Response.ok(response).build();
    } catch (WebApplicationException ex) {
      LOG.error("Error occurred while previewing {} : ", path, ex);
      throw ex;
    } catch (FileNotFoundException ex) {
      LOG.error("Error occurred while previewing {} : ", path, ex);
      throw new NotFoundFormattedException(ex.getMessage(), ex);
    } catch (Exception ex) {
      LOG.error("Error occurred while previewing {} : ", path, ex);
      throw new ServiceFormattedException(ex.getMessage(), ex);
    }
  }
@param context
@param viewConfigs : extra properties that needs to be included into configs
contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/FilePreviewService.java