superduper icon indicating copy to clipboard operation
superduper copied to clipboard

Support `base64` encoding of `bytes` as `str` in `Document`

Open blythed opened this issue 1 year ago • 0 comments

Add an optional parameter bytes_encoding to Document.encode so that we can send encoded Document instances via REST interfaces.

bytes_encoding can take 2 values: "bytes" and "base64" - i.e. config.BytesEncoding

Tasks

  • [x] Add override of CFG.bytes_encoding in:
    • [x] Encoder.encode
    • [x] Encoder.decode
    • [x] Encodable.encode
  • [x] Add override of CFG.bytes_encoding in Document.encode and Document.decode
  • [x] Unittest checking Document({'img': pil_image(PIL.Image.open(...))}).encode(bytes_encoding=BytesEncoding.base64)

blythed avatar Jan 01 '24 14:01 blythed