How do i send a file as attachment in a lambda function?

Just to clearify i’m not interested in using netlify form solution, i want to learn how to do this the manual way with lambda functions.

Currently when i send my form data to my serverless function i don’t recieve the files data (It’s getting send from client, not empty)

Console.log from serverless function:

{
  message: 'Test message',
  file: { '0': {}, '1': {} },
  name: 'Name',
  phone: 'Phone number exist, but not going to show ;)',
  email: 'example@email.com'
}

The files in the filelist are empty. I thought that maybe it was possible to encode the files to Base64 using fileReader, and then send the data. But it looks like the mail service that i’m using Mailgun doesn’t support Base64 string as attachments.

I’m not sure what else i can do, any help would be appreciated :slight_smile:

hey @HenrikDK, I am not a functions expert, but, I wonder if this might be helpful?

there may be an example in this repo that is what you are seeking: