From 5ac56832d3e3c198c83e363a8201a67ebced47ce Mon Sep 17 00:00:00 2001 From: Arcuri Davide Date: Thu, 19 Nov 2020 10:29:53 +0100 Subject: [PATCH] file attachment must be managed as binary --- cortexutils/analyzer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cortexutils/analyzer.py b/cortexutils/analyzer.py index 20825eb..f35b2f9 100644 --- a/cortexutils/analyzer.py +++ b/cortexutils/analyzer.py @@ -77,8 +77,8 @@ def build_artifact(self, data_type, data, **kwargs): if data_type == 'file': if os.path.isfile(data): (dst, filename) = tempfile.mkstemp(dir=os.path.join(self.job_directory, "output")) - with open(data, 'r') as src: - copyfileobj(src, os.fdopen(dst, 'w')) + with open(data, 'rb') as src: + copyfileobj(src, os.fdopen(dst, 'wb')) kwargs.update({'dataType': data_type, 'file': ntpath.basename(filename), 'filename': ntpath.basename(data)}) return kwargs