Blob
Immutable bytes with a MIME type.
A data channel delivers binary messages as blobs when its binary type is 'blob'.
- webrtc.models.blob.BlobPart
A part of a new
Blob. It can be astr, a bytes-like object or anotherBlob.alias of
str|bytes|bytearray|memoryview|Blob
- class webrtc.models.blob.BlobPropertyBag(type='', endings=EndingType.transparent)
The options of a new
Blob.See MDN: Blob/Blob.
- Parameters:
type (
str, optional) – The MIME type. The blob lowercases it, or leaves it empty if it has characters outside of U+0020 to U+007E.endings (
webrtc.EndingType, optional) – How the line endings of thestrparts are written. The default is'transparent', which keeps them as they are.
- class webrtc.models.blob.Blob(blob_parts=None, options=None)
Immutable bytes with a MIME type.
The bytes are held in memory.
bytes(blob)andlen(blob)give the bytes and their number, and blobs with the same bytes and type are equal. The reading methods return futures that are already done, so they must be called while an event loop runs.See MDN: Blob.
- Parameters:
blob_parts (iterable of
BlobPart, optional) – The parts, concatenated. Astris encoded as UTF-8, with lone surrogates replaced by U+FFFD.options (
BlobPropertyBag, optional) – The MIME type, and how the line endings of strings are written.
- property size: int
The number of bytes.
See MDN: Blob/size.
- Type:
- property type: str
The MIME type in lowercase, empty if unknown.
See MDN: Blob/type.
- Type:
- slice(start=0, end=None, content_type='')
Returns a new blob with a range of the bytes. Indices out of range are clamped.
See MDN: Blob/slice.
- Parameters:
- Returns:
Blob– The new blob.- Return type:
- array_buffer()
Reads the bytes. They come as
bytes, where the specification gives an array buffer.- Returns:
asyncio.Futureofbytes– The bytes, already done.- Return type:
Future[bytes]
- bytes()
Reads the bytes. They come as
bytes, where the specification gives a byte array.See MDN: Blob/bytes.
- Returns:
asyncio.Futureofbytes– The bytes, already done.- Return type:
Future[bytes]
- text()
Reads the bytes decoded as UTF-8. A leading BOM is dropped, and invalid bytes become U+FFFD.
See MDN: Blob/text.
- Returns:
asyncio.Futureofstr– The text, already done.- Return type:
Future[str]
- stream()
Returns a stream of the bytes, in
byteschunks of up to 64 KiB.See MDN: Blob/stream.
- Returns:
webrtc.ReadableStreamofbytes– The stream.- Return type:
ReadableStream[builtins.bytes]
- text_stream()
Returns a stream of
strchunks, decoded from the bytes the same waytext()does.See MDN: Blob/textStream.
- Returns:
webrtc.ReadableStreamofstr– The stream.- Return type: