aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Ionite <[email protected]>2022-11-16 15:11:41 -0500
committerGravatar Ionite <[email protected]>2022-11-16 15:11:41 -0500
commitc6a3f0ee84af75bdecbeeb65fb593d794766fdc1 (patch)
treead8b4e560d7d897ac8dcf52454e7d618fbfa5e87
parentIncreased nsjail file-size limit (diff)
Add zlib compression
-rw-r--r--snekbox/snekio.py5
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}