diff options
author | 2022-11-16 15:11:41 -0500 | |
---|---|---|
committer | 2022-11-16 15:11:41 -0500 | |
commit | c6a3f0ee84af75bdecbeeb65fb593d794766fdc1 (patch) | |
tree | ad8b4e560d7d897ac8dcf52454e7d618fbfa5e87 | |
parent | Increased nsjail file-size limit (diff) |
Add zlib compression
-rw-r--r-- | snekbox/snekio.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/snekbox/snekio.py b/snekbox/snekio.py index be0d357..12645cb 100644 --- a/snekbox/snekio.py +++ b/snekbox/snekio.py @@ -1,6 +1,7 @@ from __future__ import annotations import mimetypes +import zlib from base64 import b64encode from dataclasses import dataclass from pathlib import Path @@ -64,4 +65,6 @@ class FileAttachment: def to_dict(self) -> dict[str, str]: """Convert the attachment to a dict.""" - return {"name": self.name, "mime": self.mime, "content": b64encode(self.content).decode()} + cmp = zlib.compress(self.content) + content = b64encode(cmp).decode("ascii") + return {"name": self.name, "mime": self.mime, "content": content} |