0

first of all my code works fine but I'm trying to improve it, simply I'm trying to request an image file from host then resize it with Jimp and finally upload it to my Cloudinary account. but before sending it to Cloudinary I'm actually keeping a copy on my desk then referencing the name. so I need to know how to use that image result coming from Jimp function then send it to Cloudinary with out keeping a copy on my drive ?

let imgURL =
    "https://s3-eu-central-1.amazonaws.com/salla-cdn/FY1gllCm5QiMxstupKHqCkNOWuUxWn0jYqrBLrFI.jpeg";

const imgArr = imgURL.split("/");
const imageName = imgArr[imgArr.length - 1];

Jimp.read(imgURL)
    .then(image => {
        image.resize(500, 500).write(`./ready/${imageName}`);//RESIZING DONE
        //START UPLOADING 
cloudinary.uploader.upload(
            `./ready/${imageName}`,
            {
                crop: "limit",
                tags: "samples",
                use_filename: true,
                unique_filename: false
            },
            function(result) {
                console.log(result);
            }
        );
    })
    .catch(err => {
        console.log(err);
    });
OT AMD
  • 183
  • 5
  • 19
  • i know that i can use Cloudinary to resize it but i still need to use Jimp – OT AMD Dec 09 '19 at 21:21
  • If Jimp returns you a file buffer/stream, you can use the upload_stream method of the Cloudinary SDK to take that buffer and upload it: https://stackoverflow.com/a/56823568/21062 – Igy Dec 10 '19 at 10:49

0 Answers0