Skip to content

Commit

Permalink
🚧 [#4908] Encode attachments with base64
Browse files Browse the repository at this point in the history
This is a requirement of the plugin
  • Loading branch information
viktorvanwijk committed Dec 19, 2024
1 parent e084128 commit 57c243b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/openforms/registrations/contrib/json/plugin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import base64

from django.utils.translation import gettext_lazy as _

from openforms.submissions.models import Submission
Expand Down Expand Up @@ -26,7 +28,8 @@ def register_submission(self, submission: Submission, options: OptionsT) -> None
continue
options["form_variables"].remove(attachment.form_key)
with attachment.content.open("rb") as f:
values[attachment.form_key] = f.read()
f.seek(0)
values[attachment.form_key] = base64.b64encode(f.read()).decode()

# TODO-4908: what should the behaviour be when a form
# variable is not in the data or static variables?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_submission_with_json_backend(self):
"values": {
"firstName": "We Are",
"lastName": "Checking",
"file": b"This is example content.",
"file": "VGhpcyBpcyBleGFtcGxlIGNvbnRlbnQu",
"auth_bsn": "123456789",
}
}
Expand Down

0 comments on commit 57c243b

Please sign in to comment.