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.

hello sorry im new, can you elaborate more about why netlify doesnt support multiplart/form-data ?

i’ve been trying to figure out, why the netlify-function cannot post my formData, i’ve been debugging so long, i thought my formdata is invalid or another reason.
if it’s true, why it is not documented too ?

I’ve responded to your other topic asking you to try something like fetch instead. Perhaps that would help. I may be incorrect with lambda functions not supporting formData but I have not personally been able to get a function receive multipart formData. Let me know how it goes.

Still the issue is happening. Any fix for this?
Read the following post → Trouble with handling files in Netlify Function

Is there any update on multipart/form-data in netlify?

Hey there, @Coderr :wave:

Thanks for following up. I see you are also in communication with one of our Support Engineers on this thread: Trouble with handling files in Netlify Function - #8 by Coderr

We ask that folks keep related questions on one thread so that we can streamline support and work with you efficiently. Please continue the conversation in the thread I linked above.

Thanks so much!

@hillary ,
I think @Coderr 's issue is related here. I’m also searching for answers on sending multipart/form-data and some answers would be greatly beneficial and appreciated.

We are limited by what format to send data as in downstream endpoints, and the middleman is Netlify functions. Is it or is it not supported by Netlify functions? Are there plans to support this format?

1 Like

Hi @Cakeplease,

The other thread has been updated with a workaround. Would you please check it and leave your thoughts there?