diff --git a/src/openforms/registrations/contrib/json/plugin.py b/src/openforms/registrations/contrib/json/plugin.py index bff7f72a62..76fd78b151 100644 --- a/src/openforms/registrations/contrib/json/plugin.py +++ b/src/openforms/registrations/contrib/json/plugin.py @@ -1,3 +1,5 @@ +import base64 + from django.utils.translation import gettext_lazy as _ from openforms.submissions.models import Submission @@ -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? diff --git a/src/openforms/registrations/contrib/json/tests/test_backend.py b/src/openforms/registrations/contrib/json/tests/test_backend.py index fb4c8d0dbc..71025c4b41 100644 --- a/src/openforms/registrations/contrib/json/tests/test_backend.py +++ b/src/openforms/registrations/contrib/json/tests/test_backend.py @@ -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", } }