You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2020/04/20 08:08:01 UTC

[GitHub] [rocketmq-client-python] zhxsxuan opened a new issue #87: producer can't send byte string of an image file

zhxsxuan opened a new issue #87:
URL: https://github.com/apache/rocketmq-client-python/issues/87


   I tried to send sync a byte string read from an image to RMQ by the following code:
   ```
   with open("model/test.jpeg", "rb") as f:
       img_str = f.read()
   msg.set_body(img_str)
   ret = producer.send_sync(msg)
   ```
    but the message body a consumer received is only a part of the byte string
   ```
   b'\xff\xd8\xff\xdb'
   ```
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq-client-python] zhxsxuan commented on issue #87: producer can't send byte string of an image file

Posted by GitBox <gi...@apache.org>.
zhxsxuan commented on issue #87:
URL: https://github.com/apache/rocketmq-client-python/issues/87#issuecomment-617592278


   > the py SDK does not support the binary message body.
   > maybe you can encode the byte body using base64 encoding before sending and decode it before consuming.
   > another way, you can try to add a new API to set a binary message body using a special C API "SetByteMessageBody" instead.
   
   I tried changing the set_body function as following
   ```
       def set_body(self, body):
           if isinstance(body, binary_type):
               ffi_check(dll.SetByteMessageBody(self._handle, _to_bytes(body), len(body)))
           ffi_check(dll.SetMessageBody(self._handle, _to_bytes(body)))
   ```
   But the message received was not changed.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq-client-python] ShannonDing commented on issue #87: producer can't send byte string of an image file

Posted by GitBox <gi...@apache.org>.
ShannonDing commented on issue #87:
URL: https://github.com/apache/rocketmq-client-python/issues/87#issuecomment-616402296


   the py SDK does not support the binary message body.
   maybe you can encode the byte body using base64 encoding before sending and decode it before consuming.
   another way, you can try to add a new API to set a binary message body using a special C API "SetByteMessageBody" instead.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org