private void uploadFile(final String filePath, InputStream uploadedInputStream)
      throws IOException, InterruptedException {
    int read;
    byte[] chunk = new byte[1024];
    FSDataOutputStream out = null;
    try {
      out = getApi().create(filePath, false);
      while ((read = uploadedInputStream.read(chunk)) != -1) {
        out.write(chunk, 0, read);
      }
    } finally {
      if (out != null) {
        out.close();
      }
    }
  }
takes context and any extra custom properties that needs to be included into config
@param context
@param customProperties
contrib/views/commons/src/main/java/org/apache/ambari/view/commons/hdfs/UploadService.java