From 640e8cc9c8e945305655eded178b3fffa0085d37 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Fri, 20 Dec 2019 11:55:59 -0500 Subject: [PATCH] Only store bytes to s3 via boto2. https://github.com/boto/boto/issues/2868 In python 3 contentfile can act like a file but return unicode strings. Boto doesn't like that and it causes issues when encoding the bytes for transfer to s3. --- lms/djangoapps/instructor_task/models.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lms/djangoapps/instructor_task/models.py b/lms/djangoapps/instructor_task/models.py index 3efe99ba4d..e142fe8edd 100644 --- a/lms/djangoapps/instructor_task/models.py +++ b/lms/djangoapps/instructor_task/models.py @@ -279,6 +279,11 @@ class DjangoStorageReportStore(ReportStore): object, ready to be read from the beginning. """ path = self.path_to(course_id, filename) + # See https://github.com/boto/boto/issues/2868 + # Boto doesn't play nice with unicod in python3 + if not six.PY2: + buff = ContentFile(buff.read().encode('utf-8')) + self.storage.save(path, buff) def store_rows(self, course_id, filename, rows):