Use simpler conversion to string

This commit is contained in:
Christopher Broderick 2023-03-25 13:25:22 +00:00
parent 4cd66d7e0c
commit 8cb3d43311

View File

@ -687,8 +687,7 @@ def extract_part_data(
name = f"part-{counter}{ext}" name = f"part-{counter}{ext}"
else: else:
name = f"part-{counter}_{name}" name = f"part-{counter}_{name}"
payload = decodeUnknown(part.get_charset(), part.as_bytes( payload = part.as_string() if part.is_multipart() else part.get_payload(decode=True)
)) if part.is_multipart() else part.get_payload(decode=True)
files.append(SimpleUploadedFile(name, payload, mimetypes.guess_type(name)[0])) files.append(SimpleUploadedFile(name, payload, mimetypes.guess_type(name)[0]))
logger.debug("Found MIME attachment %s", name) logger.debug("Found MIME attachment %s", name)
return part_body, part_full_body return part_body, part_full_body