code: private static Long getContentSize(final Node ds) {
          try {
              long size = 0L;
              if (ds.hasNode(JCR_CONTENT)) {
                  final Node contentNode = ds.getNode(JCR_CONTENT);
  
                  if (contentNode.hasProperty(JCR_DATA)) {
                      size =
                              ds.getNode(JCR_CONTENT).getProperty(JCR_DATA)
                                      .getBinary().getSize();
                  }
              }
  
              return size;
  
          } catch (final RepositoryException e) {
              throw new RepositoryRuntimeException(e);
          }
      }
docs: Get the size of the JCR content binary property
  
  @param ds the given node
  @return size of the binary content property