Netlify server functions unable to handle multipart/form-data

Considering exports.handler=async function(event, context, callback){...
event.body is giving strange string instead of usually seen data send by multipart/form-data.

Expected si something recognizable as -----------------------------1057922449146384648951229522\r\nContent-Disposition: form-data;.....,
getting LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS01ODYyMDYyNTQxMDM1MjM5MzQ5ODM2OTU3NjU0DQpDb250ZW50LURpc3Bvc2l0aW9uO....

The strange string is the correct string transformed by base64encoded. My temporary solution until your fix is event.body=Buffer.from(event.body, 'base64');

Will you fix it?


I’m afraid Netlify functions do not currently support multipart/form-data. We’re aware of this issue and are tracking it internally; I’ve added this issue to our internal tracker so you’ll be notified when it’s fixed.

In the meantime, workarounds include posting the data as standard form data (if it will fit!) or the temporary fix you’re already using.

No, they are supporting, but the behavior on localhost is broken and Buffer received is different! If the data sent is svg image, it works on both comparing to jpeg or some compressed files. The reason behind are special characters and broken decodings for localhost. Localhost served by run start:lambda doesn’t have base64 enabled compared to your lambda functions on server. It is creating the issues with multipart/form-data. Local lambda functions behaviour is not the same as on your server.


Yes, netlify-lambda does indeed work differently from deployed Netlify functions. As was mentioned, we do not support multipart/form-data on deployed Netlify functions. Are you saying you are able to send multipart/form-data to your deployed Netlify function?

As far are local testing goes, could you give netlify dev (link) a try and see if that works better? It may have the same behavior though.