b2sdk._internal.stream.hashing StreamWithHash

class b2sdk._internal.stream.hashing.StreamWithHash(stream, stream_length=None)[source]

Bases: ReadOnlyStreamMixin, StreamWithLengthWrapper

Wrap a file-like object, calculates SHA1 while reading and appends hash at the end.

__init__(stream, stream_length=None)[source]
Parameters:

stream – the stream to read from

seek(pos, whence=0)[source]

Seek to a given position in the stream.

Parameters:

pos (int) – position in the stream

read(size=None)[source]

Read data from the stream.

Parameters:

size (int) – number of bytes to read

Returns:

read data

Return type:

bytes|None

classmethod get_digest()[source]