How to upload a file to Supabase storage using Nodejs.
I am working on a hobby project using Nodejs for my backend. I am trying to upload files to Supabase storage using api route
/upload
. I have a form with <input type="file" name="logo" id="logo">
But, I have not found any helpful resource for this. Can anyone help me with the code or point to the correct tutorial or article?7 Replies
Wdym by api route /upload?
here is a general hint
in your api, make sure to have a function that handles uploading using
check the docs for more info
https://supabase.com/docs/reference/javascript/storage-from-upload
i mean, I am building a basic CRUD app with Nodejs, Supabase and EJS as the view engine. One of my API is
localhost:3000/api/upload.
A form in my index.ejs
file sends the image to this API. Can you explain the const avatarFile = event.target.files[0]
please.
Here's my code for the API route In your API route, you would handle the file data from the form and pass it to the
uploadFile
function. You might need to use middleware like multer
for handling multipart/form-data in Node.js.okay. Got the idea. Thanks.
for
const avatarFile = event.target.files[0]
can I see how are you handling the file upload from the client side?Here's my client-side code: And I am passing file to Supabase as just
req.body.logo