@POST
  @Path("/concat")
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_OCTET_STREAM)
  public Response concat(final DownloadRequest request) {
    LOG.info("Starting concat files.");
    try {
      StreamingOutput result = new StreamingOutput() {
        public void write(OutputStream output) throws IOException,
            ServiceFormattedException {
          FSDataInputStream in = null;
          for (String path : request.entries) {
            try {
              try {
                in = getApi().open(path);
              } catch (AccessControlException ex) {
                LOG.error("Error in opening file {}. Ignoring concat of this files.", path.substring(1), ex);
                continue;
              }

              long bytesCopied = IOUtils.copyLarge(in, output);
              LOG.info("concated file : {}, total bytes added = {}", path, bytesCopied);
            } catch (Exception ex) {
              LOG.error("Error occurred : ", ex);
              throw new ServiceFormattedException(ex.getMessage(), ex);
            } finally {
              if (in != null)
                in.close();
            }
          }
        }
      };
      ResponseBuilder response = Response.ok(result);
      if (request.download) {
        response.header("Content-Disposition", "attachment; filename=\"concatResult.txt\"").type(MediaType.APPLICATION_OCTET_STREAM);
      } else {
        response.header("Content-Disposition", "filename=\"concatResult.txt\"").type(MediaType.TEXT_PLAIN);
      }
      return response.build();
    } catch (WebApplicationException ex) {
      LOG.error("Error occurred ", ex);
      throw ex;
    } catch (Exception ex) {
      LOG.error("Error occurred ", ex);
      throw new ServiceFormattedException(ex.getMessage(), ex);
    }
  }
Concatenate files
@param request download request
@return response with all files concatenated
contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/DownloadService.java