nats-io / nats.py

Python3 client for NATS
https://nats-io.github.io/nats.py/
Apache License 2.0
874 stars 184 forks source link

Nats object store image with header data #565

Open paliriv opened 3 months ago

paliriv commented 3 months ago

Observed behavior

When I put an image into the object store that has header data. CLI nats is unable to view or provide information on it. It either hangs or states that the image is corrupt.

Expected behavior

I would like to view Images that are in object store and their metadata through the cli.

Server and client version

nats-server: v2.10.12 nats CLI : 0.1.4

Host environment

OS Name Microsoft Windows 10 IoT Enterprise LTSC python v3.11.1

Steps to reproduce

create a bucket push image into bucket with headers. in nats cli > nats object ls "streamName"

` async def push_image_to_bucket(self, image: np.ndarray, result_data: dict, parameters: dict): self.logger.debug('pushing image')

convert bgr to rgb

    im_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
    success, encoded_img = cv2.imencode('.jpg', im_rgb)
    data_bytes = encoded_img.tobytes()
    info = await self.object_store.put(name='test_image.jpg', data=data_bytes, meta=ObjectMeta(
        description='image for frontend display', 
        headers={'type': "image/jpg", 
                'source': "vision", 
                'destination': "gui", 
                'parameters': parameters,
                'result-data': result_data}
    ))
    print(f'Put entry {info.name} ({info.size} bytes) "{info.description}"')
    self.logger.debug(f'Put entry {info.name} ({info.size} bytes) "{info.description}"')`