0

i want to input push value to variable but ended up not get input to the variable.

const saveFile = async (file, name) => {
  const data = fs.readFileSync(file.filepath);
  const hasil = await sharp(data).webp({ quality: 20 }).toBuffer();
  var urlImg = [];
  cloudinary.uploader
    .upload_stream(
      { resource_type: "image", folder: "floris", public_id: name },
      (err, image) => {
        urlImg.push(image);
        console.log(image.url);
      }
    )
    .end(hasil);
  return urlImg;
};

output of that

[] //output from urlImg
http://res.cloudinary.com/daw1nuqgv/image/upload/v1672047974/floris/6-rc9R4-20221226164611.webp // Output from console.log(image.url)
adiga
  • 34,372
  • 9
  • 61
  • 83
Tegar
  • 1

0 Answers0