How to convert Buff to File Without locally saving it

How do you convert buff to a file? I have an endpoint that modifies images uploaded, and that endpoint returns buffs. Afterwards, I need these buffs to be uploaded in which I will call a service to do that, and the service I'm using requires File to upload the image.

How would I do it so that the image is not saved and just passed to the function?

    const imgBuff = images[0].image;

    /* I need to save it as a variable and be passed as an imageFile, instead of saving it */
    const fs = require('fs');
    fs.writeFile('./image.jpg', Buffer.from(), (err) => {
      if (err) throw err;
      console.log('The file has been saved!');
    });

    await uploadImage(imageFile)
Was this page helpful?