I would like to use Supabase's own REST API instead of the JavaScript client library (https://supabase.com/docs/reference/javascript/storage-from-upload) provided by them.
Something like this:
const productImageFile = productData.image.split("\\")[2]; const sanitizedProductImageFile = productImageFile.replace( /[^a-zA-Z0-9._-]/g,"_" ); const file = new File([productData.image], sanitizedProductImageFile); const formData = new FormData(); formData.append("file", file); const productImageBucketApiResponse = await fetch( `${import.meta.env.VITE_SUPABASE_URL}/storage/v1/object/${import.meta.env.VITE_SUPABASE_BUCKET_NAME}/images`, { method: "POST", headers: { apikey: import.meta.env.VITE_SUPABASE_KEY, }, body: formData, } );