Skip to content
New issue

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

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

Already on GitHub? # to your account

How do you publish binary data? #514

Closed
lenzenmi opened this issue Nov 12, 2016 · 2 comments
Closed

How do you publish binary data? #514

lenzenmi opened this issue Nov 12, 2016 · 2 comments
Labels

Comments

@lenzenmi
Copy link

The documentation mentions how to consume binary data. It does not say how to produce one.

Sending a buffer or Uint8Array sends only their string representation.

@hyperlink
Copy link
Collaborator

It looks like the code from #29 is still in place. Try setting the messages attribute in the payload to be a Buffer. Does this not work?

@lenzenmi
Copy link
Author

Thanks for the tip. A Buffer object does work. I was trying to send a TypedArray and the associated .buffer attribute of the TypedArray with no luck.

Doing this works:
messages: Buffer.from(data.buffer)

It would be nice to have a note in the documentation like there is for consuming a binary message:

how do I publish binary data?
Set the messages attribute in the payload to a Buffer. TypedArrays such as Uint8Array are not supported and need to be converted to a Buffer.

hyperlink added a commit that referenced this issue Nov 16, 2016
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants