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

@mander if you use the code I provided here

async function uploadImages(images, bucket, path) {
    const storage = wwLib.wwPlugins.supabaseAuth.publicInstance.storage;
    const promises = [];

    for (let i = 0; i < images.length; i++) {
      const image = images[i];
      const randomName = generateRandomName(); // Implement your random name generation logic
      const filePath = `${path}/${randomName}.jpg`;

      const promise = storage
        .from(bucket) // Your bucket name goes here
        .upload(filePath, image, {
          cacheControl: '3600',
          upsert: true,
        });

      promises.push(promise);
    }

    // Wait for all upload promises to complete
    await Promise.all(promises);
    console.log('Promises fulfilled.');
  }

  // Generate a random name function (you can customize this)
  function generateRandomName() {
    const randomString = Math.random().toString(36).substring(7);
    return randomString;
  }

  // Call the uploadImages function
  uploadImages(variables[/* Input File Drop - value */ 'cdd23a87-baa8-4fe8-9782-69efde43c67b-value'], 'bucket_name', 'your_path/your_folder') // You just input your [ Input File Drop - value ] here
    .then(() => {
    console.log('Images uploaded.');
    })
    .catch((error) => {
      console.error('Error uploading images:', error);
    });
    

You can use the variable from the upload directly. Like this:

Seems to work,

No need to overcomplicate it by using queries and such.

2 Likes