def file_chunks(self, fp):
        """
        Yields chunks of a file.
        """
        fsize = utils.file_size(fp)
        offset = 0
        if hasattr(fp, 'readinto'):
            while offset < fsize:
                nb = fp.readinto(self._internal)
                yield self.buf[:nb]
                offset += nb
        else:
            while offset < fsize:
                nb = min(self.chunk_size, fsize - offset)
                yield fp.read(nb)
                offset += nb
dataset/ETHPy150Open ipfs/py-ipfs-api/ipfsApi/multipart.py/BufferedGenerator.file_chunks/original