How to post binary data (when not JSON encoded)?

Where do the format constants live now ? Tried the places mentioned in the documentation

https://docs.couchbase.com/python-sdk/current/concept-docs/nonjson.html

couchbase.exceptions.ValueFormatException: <Couldn't encode value, inner_cause=Object of type bytes is not JSON serializable, C Source=(src/convert.c,145), 

https://docs.couchbase.com/python-sdk/2.5/nonjson.html#using-the-raw-format

couchbase.FMT_BYTES

But in the end had to dig through the library code to find something that actually worked…

from couchbase_core._libcouchbase import FMT_BYTES
bucket.upsert(key, val, format=FMT_BYTES)

Hello @afbjorklund sorry for the inconvenience caused. You are right and the solution you have is also correct.
What is missing is documentation around using transcoders we have a ticket in place to address that .
Once again thank you for your contribution and patience.

No worries, but I think it should be documented - if it is still supported, that is ?

I got the feeling that both memcached and binary documents are deprecated…

Not sure what would be the appropriate way of doing this in JSON, base-64 ?

class Base64Encoder(json.JSONEncoder):
    # pylint: disable=method-hidden
    def default(self, o):
        if isinstance(o, bytes):
            return base64.b64encode(o).decode()
        return json.JSONEncoder.default(self, o)

Since I am using it as a cache, using JSON would not be the preferred method.