Skip to content

ChildProcessAdapter cannot read/write binary files #38

@jmoo

Description

@jmoo

This is caused by WyriHaximus/reactphp-child-process-messenger use of json_encode/json_decode which does not support binary strings.

I'd make a pull request but I'm not sure if this should be fixed here by (probably base64) encoding the payloads or if it should be fixed in WyriHaximus/reactphp-child-process-messenger by moving to a binary format for rpc

Example:

$loop = \React\EventLoop\Factory::create();
$filesystem = \React\Filesystem\Filesystem::create($loop);

$contents = base64_decode('UEsDBAoAAAAAAEw400'); // start of zip header
$filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'bin.data';

echo 'Using ', get_class($filesystem->getAdapter()), PHP_EOL;
$filesystem->file($filename)->putContents($contents)->then(function ($contents) use ($filename) {
    echo file_get_contents($filename), PHP_EOL;
}, function (Exception $e) {
    echo $e->getMessage(), PHP_EOL;
    echo $e->getTraceAsString(), PHP_EOL;
});

$loop->run();

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions