[importer] Error with Python 3 when trying to upload file to S3 bucket
@@ -27,9 +27,9 @@ import logging
import sys
if sys.version_info[0] > 2:
- from io import StringIO as string_io
+ from io import BytesIO as stream_io
else:
- from cStringIO import StringIO as string_io
+ from cStringIO import StringIO as stream_io
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.files.uploadhandler import FileUploadHandler, SkipFile, StopFutureHandlers, StopUpload, UploadFileException
@@ -122,7 +122,8 @@ class S3FileUploadHandler(FileUploadHandler):
def _get_s3fs(self, request):
- fs = get_client(user=request.user.username) # Pre 6.0 request.fs did not exist, now it does. The logic for assigning request.fs is not correct for FileUploadHandler.
+ # Pre 6.0 request.fs did not exist, now it does. The logic for assigning request.fs is not correct for FileUploadHandler.
+ fs = get_client(user=request.user.username)
if not fs:
raise S3FileUploadError(_("No S3 filesystem found."))
@@ -151,7 +152,7 @@ class S3FileUploadHandler(FileUploadHandler):
def _get_file_part(self, raw_data):
- fp = string_io()
+ fp = stream_io()
fp.write(raw_data)
fp.seek(0)
return fp
