public static Meta generateMeta ( @ NotNull final StreamProvider streamProvider ) throws IOException { final MessageDigest digest = sha256 ( ) ; final byte [ ] buffer = new byte [ 0x10000 ] ; long size = 0 ; try ( InputStream stream = streamProvider . getStream ( ) ) { while ( true ) { int read = stream . read ( buffer ) ; if ( read <= 0 ) break ; digest . update ( buffer , 0 , read ) ; size += read ; } } return new Meta ( new String ( Hex . encodeHex ( digest . digest ( ) ) ) , size ) ; }
Generate object metadata .