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.
This commit is contained in:
Feanil Patel
2019-12-20 11:55:59 -05:00
parent b1b5403041
commit 640e8cc9c8

View File

@@ -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):