How to store a binary file by php-client

hello ~

I want to save some small binary file which is about 200K to aerospick database ,but I got the error “ERR_RECORD_TOO_BIG” ~

first I defined a class

class cls{
    public $content;
}

and then read the file and save to database

                ....
    $fileContent = file_get_contents("test.dat");
    $obj = new cls();
    $obj->content = fileContent;
    $bins = array('dat'=>$obj);
    $status = $db->put($key, $bins);
                 ....

I my opinion , maybe there is something wrong with the serialize function .

who knows the right way to save the small binary file by php client?

What is your configured write block size for the namespace. The maximum allowed record size is <= write block size. You can check it out in namespace section in /etc/aerospike/aerospike.conf file. If the write block size is configured < 200k then you will see symptoms as observed and increasing it should work.

For more detail refer to link

– R

thank you for your suggestion!

Please make sure to read the README at the top of the documentation of the GitHub repo for a problem that may occur with storing binary data in strings. Specifically if your binary data may include a null byte (\0) in the middle of the string. There’s a workaround described there.