What's the best way tu opload a file directly to Supabase storage?

Also, this is the JS code to make it work for multiple files

var formData = new FormData();
var formFiles = document.querySelector('#fileUploaderID input').files;
var fileName = "name";

    for (let i=0; i < formFiles.length; i++) {
    fileName = your File name path[i]valuename;
    formData.append('files[]', formFiles[i]);
 axios.post("https://yourURL.supabase.co/storage/v1/object/bucketName/folderName/"+fileName, formData,{
    headers:{
        "Content-Type": "multipart/form-data",
        "Authorization": "Your authentication token"
    }
})
    }

3 Likes