uploading file to storage convert file to garbage
I am trying to upload a file using server side API in Nuxt and the formidable package. For some reason the file is converting to garbage on supabase
here is my code
here is my code

const {fields, files} = response;
const avatar = files.avatar;
// creates a valid name by removing spaces
const fileName = encodeURIComponent(
avatar.originalFilename.replace(/\s/g, "-")
);
// renames the file in the directory
fs.renameSync(avatar.filepath, fileName);
console.log(avatar)
const avatarData = fs.readFileSync(fileName)
const {data, error} = await client.storage
.from("site")
.upload("public/" + Date.now() + "-" + fileName, avatarData, {
cacheControl: "3600",
upsert: false,
});