Is it possible to send a file to an edge function and save the file in Supabase storage?

I'm having a hard time sending a file to an edge function for it to be saved. Perhaps this is not the right thing to do but I was wondering if this was possible.

const file = e.target.files[0];

let formData = new FormData();
formData.append("file", file);

const { data, error } = await supabaseClient.functions.invoke(
  "media-upload",
  {
    body: JSON.stringify({
      file: formData,
    }),
  }
);


This is how I send my file to the edge function but inside the function I can't do file.getAll("file").

Anyone knows what I'm doing wrong?
Was this page helpful?