Пример #1
0
    def stream_file_by_md5(self, checksum):
        """Stream file based on MD5 checksum.

        Args:
            checksum (str): MD5 hash of the file.

        Returns:
            Returns a stream of the requested file.
        """
        response = self._search_by_hash(checksum, MD5)
        events = response[u"fileEvents"]
        info = _get_version_lookup_info(events)
        if not len(events) or not info:
            raise Py42ChecksumNotFoundError(response, u"MD5", checksum)
        return self._stream_file(checksum, info)
Пример #2
0
    def stream_file_by_sha256(self, checksum):
        """Stream file based on SHA256 checksum.

        Args:
            checksum (str): SHA256 hash of the file.

        Returns:
            Returns a stream of the requested file.
        """
        response = self._search_by_hash(checksum, SHA256)
        events = response["fileEvents"]
        info = _get_version_lookup_info(events)
        if not len(events) or not info:
            raise Py42ChecksumNotFoundError(response, "SHA256", checksum)
        return self._stream_file(checksum, info)
Пример #3
0
    def stream_file_by_sha256(self, checksum):
        """Stream file based on SHA256 checksum.

        Args:
            checksum (str): SHA256 hash of the file.

        Returns:
            Returns a stream of the requested file.
        """
        response = self._search_by_hash(checksum, SHA256)
        events = response[u"fileEvents"]
        if not len(events):
            raise Py42ChecksumNotFoundError(response, u"SHA256", checksum)
        md5_hash = events[0][u"md5Checksum"]

        return self._stream_file(self._find_file_versions(md5_hash, checksum), checksum)
Пример #4
0
    def stream_file_by_md5(self, checksum):
        """Stream file based on MD5 checksum.

        Args:
            checksum (str): MD5 hash of the file.

        Returns:
            Returns a stream of the requested file.
        """
        response = self._search_by_hash(checksum, MD5)
        events = response[u"fileEvents"]
        if not len(events):
            raise Py42ChecksumNotFoundError(response, u"MD5", checksum)
        sha256_hash = events[0][u"sha256Checksum"]
        return self._stream_file(
            self._find_file_versions(checksum, sha256_hash), checksum
        )