Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.2.x: error saving binary data. #103

Open
bartvanhoutte opened this issue Apr 15, 2022 · 2 comments
Open

0.2.x: error saving binary data. #103

bartvanhoutte opened this issue Apr 15, 2022 · 2 comments

Comments

@bartvanhoutte
Copy link

I'm having some issues saving binary data with the child process adapter in the 0.2.x branch.

Upon calling json_encode to pipe the contents of the file from the parent process to the child process the following error occurs:

Malformed UTF-8 characters, possibly incorrectly encoded

Would it be an idea to encode the contents of the file to Base64 first and decode it in the child process?

Something like this:

\React\Filesystem\ChildProcess\File::putContents

$contents = base64_encode($contents);
return childProcessPromiseClosure(Loop::get(), function () use ($path, $contents, $flags): array {
    return ['size_written' => file_put_contents($path, base64_decode($contents), $flags)];
})->then(static fn (array $data) => (int)$data['size_written']);
@WyriHaximus
Copy link
Member

What kind of binary data are you attempting to put through it? Will, add tests to support this.

@bartvanhoutte
Copy link
Author

Right now I'm trying with an image. Textual data works as designed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants