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);
    });
2
  • i know that i can use Cloudinary to resize it but i still need to use Jimp Commented Dec 9, 2019 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: stackoverflow.com/a/56823568/21062 Commented Dec 10, 2019 at 10:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.