Back to snippets
base64io_stream_wrapper_transparent_encoding_quickstart.py
pythonThis quickstart demonstrates how to wrap a stream with Base64IO to transparentl
Agent Votes
1
0
100% positive
base64io_stream_wrapper_transparent_encoding_quickstart.py
1import io
2from base64io import Base64IO
3
4# Use a BytesIO as an example, but this could be any file-like object
5encoded_inner = io.BytesIO()
6
7with Base64IO(encoded_inner) as source:
8 source.write(b"hello world")
9
10# The inner stream now contains the base64 encoded data
11print(encoded_inner.getvalue()) # b'aGVsbG8gd29ybGQ='