Use regular expressions to pull datastream [version]
        details (id, mimetype, size, and checksum) for binary content,
        in order to sanity check the decoded data.

        :param dsinfo: text content just before a binaryContent tag
        :returns: dict with keys for id, mimetype, size, type and digest,
            or None if no match is found

def get_datastream_info(self, dsinfo):
        '''Use regular expressions to pull datastream [version]
        details (id, mimetype, size, and checksum) for binary content,
        in order to sanity check the decoded data.

        :param dsinfo: text content just before a binaryContent tag
        :returns: dict with keys for id, mimetype, size, type and digest,
            or None if no match is found
        '''
        # we only need to look at the end of this section of content
        dsinfo = dsinfo[-750:]
        # if not enough content is present, include the end of
        # the last read chunk, if available
        if len(dsinfo) < 750 and self.end_of_last_chunk is not None:
            dsinfo = self.end_of_last_chunk + dsinfo

        # force text needed for python 3 compatibility (in python 3
        # dsinfo is bytes instead of a string)
        try:
            text = force_text(dsinfo)
        except UnicodeDecodeError as err:
            # it's possible to see a unicode character split across
            # read blocks; if we get an "invalid start byte" unicode
            # decode error, try converting the text without the first
            # character; if that's the problem, it's not needed
            # for datastream context
            if 'invalid start byte' in force_text(err):
                text = force_text(dsinfo[1:])
            else:
                raise err

        # in case the text contains multiple datastream ids, find
        # all matches and then use the last, since we want the last one
        # in this section, just before the datastream content
        matches = list(self.dsinfo_regex.finditer(text))
        if matches:
            infomatch = matches[-1]
            return infomatch.groupdict()