How Cloudinary works

Besides we storing files on Cloudinary, we can use a powerful API to manipulate and transform images, apply effects, resize, and do a lot more things without using any software on our machine.

Let's go back to the books.js controller to check what we used. We extracted the extra code inside the promises function to focus on the highlighted lines of code:

      cloudinary.uploader.upload(imageFile, 
            { 
              tags: 'photobook', 
              folder: req.body.category + '/', 
              public_id: req.files.image.originalFilename 
              // eager: { 
              //   width: 280, height: 200, crop: "fill", gravity: "face" 
             // } 
            }) 
              .then(function (image) { 
               ... 
             }) 
             .then(function (photo) { 
                ... 
              }) 
              .finally(function () { 
                ... 
              }); 

Here we set up a folder, folder: req.body.category, to store our images, ...

Get Node.js 6.x Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.