private function insertChunksFromFile($handle, $record, &$md5)
    {
        $written = 0;
        $offset = 0;
        $i = 0;

        $fileId = $record['_id'];
        $chunkSize = $record['chunkSize'];

        $hash = hash_init('md5');

        rewind($handle);
        while (! feof($handle)) {
            $data = stream_get_contents($handle, $chunkSize);
            hash_update($hash, $data);
            $this->insertChunk($fileId, $data, $i++);
            $written += strlen($data);
            $offset += $chunkSize;
        }

        $md5 = hash_final($hash);

        return $written;
    }
private function insertChunksFromFile($handle, $record, &$md5)
    {
        $written = 0;
        $offset = 0;
        $i = 0;

        $fileId = $record['_id'];
        $chunkSize = $record['chunkSize'];

        $hash = hash_init('md5');

        rewind($handle);
        while (! feof($handle)) {
            $data = stream_get_contents($handle, $chunkSize);
            hash_update($hash, $data);
            $this->insertChunk($fileId, $data, $i++);
            $written += strlen($data);
            $offset += $chunkSize;
        }

        $md5 = hash_final($hash);

        return $written;
    }
private function insertChunksFromFile ( $ handle , $ record , & $ md5 ) { $ written = 0 ; $ offset = 0 ; $ i = 0 ; $ fileId = $ record [ '_id' ] ; $ chunkSize = $ record [ 'chunkSize' ] ; $ hash = hash_init ( 'md5' ) ; rewind ( $ handle ) ; while ( ! feof ( $ handle ) ) { $ data = stream_get_contents ( $ handle , $ chunkSize ) ; hash_update ( $ hash , $ data ) ; $ this -> insertChunk ( $ fileId , $ data , $ i ++ ) ; $ written += strlen ( $ data ) ; $ offset += $ chunkSize ; } $ md5 = hash_final ( $ hash ) ; return $ written ; }
Reads chunks from a file and writes them to the database

@param resource $handle
@param array $record
@param string $md5
@return int Returns the number of bytes written to the database
Reads chunks from a file and writes them to the database