255) { // Get file hash sum $basename = md5_file( $argv[2] ); // Dump event print( 'Filename to long, used md5_file as key...' . PHP_EOL ); } // Split content to smaller parts (according to the protocol limits) $pieces = str_split( base64_encode( file_get_contents( $argv[2] ) ), 3072 ); // Count total pieces $total = count( $pieces ); // Create namespace to collect there data pieces $ns = _exec( $argv[1], sprintf( "keva_namespace '%s'", str_replace( "'", "\'", $basename ) ) ); // Validate namespace created if (empty($ns->namespaceId)) { print( 'could not create namespace record' . PHP_EOL ); exit; } // Create meta record print_r( _exec( $argv[1], sprintf( 'keva_put %s %s %s', $ns->namespaceId, '_CLITOR_IS_', _CLITOR_IS_ ) ) ); // Begin pieces saving foreach ($pieces as $key => $value) { print_r( _exec( $argv[1], sprintf( "%s '%s' '%s' '%s'", 'keva_put', $ns->namespaceId, $key, $value ) ) ); // Apply delays to prevent too-long-mempool-chain reject $delay = isset($argv[4]) && $argv[4] > 0 ? (int) $argv[4] : 60; printf( '%s/%s sent, waiting %s seconds...' . PHP_EOL, $key + 1, $total, $delay ); sleep( $delay ); } // Done printf( 'data successfully sent to namespace "%s"' . PHP_EOL, $ns->namespaceId ); printf( "run to extract: /usr/bin/php '%s/get.php' '%s' '%s' '/path/to/%s'" . PHP_EOL, __DIR__, $argv[1], $ns->namespaceId, $basename );