You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When submitting a file using a (non-Netlify) form to a Netlify Function, we have to use multipart/form-data content-type which is encoded according to the above post. Thus, we need to decode it as:
Buffer.from(event.body,'base64').toString('utf8')
However, when doing the same in CLI, the body is not encoded and available easily as event.body.
Describe the bug:
The production server encodes the function's
event.body
tobase64
except for a few content-types as mentioned here: https://answers.netlify.com/t/changed-behavior-in-function-body-encoding/19000.When submitting a file using a (non-Netlify) form to a Netlify Function, we have to use
multipart/form-data
content-type which is encoded according to the above post. Thus, we need to decode it as:However, when doing the same in CLI, the body is not encoded and available easily as
event.body
.It can easily be worked around like:
But, it leads to confusion.
To reproduce:
Steps to reproduce the behavior:
netlify dev
.event.body
. Then, log the same in production environment.Configuration:
netlify.toml
:System info:
Expected behaviour:
The CLI should encode
event.body
tobase64
.Additional context:
Slack discussion (INTERNAL ONLY): https://netlify.slack.com/archives/C023PC3D08J/p1631194079008400
The text was updated successfully, but these errors were encountered: