Upload Multiple images to cloudinary Node, MongoDB, Express

Upload Multiple images to cloudinary Node, MongoDB, Express

·

0 min read

Hello there In this post we are going to create a backend Node JS server that uses the cloudinary library to upload multiple images at once because cloudinary doesn't support multiple images by default so we are going to find a way around it. Brace yourselves, I hope you are excited as I am.

Requirements

We will need the following installed on our machines to get started;

Let get started.

First, we create our project folder and also initialize our project using

The following

 mkdir cloud_mutilple_image
 cd cloud_mutilple_image
 npm inti

which would create a package.json file for us.

PROJECT STRUCTURE

Next, we would structure our project, in the root folder we would need to create a server.js file, which would be the main entry point of our application, then we will need a helper folder to contain our application helper.js file. Our project structure would look like this.

Screen Shot 2019-11-08 at 6.06.33 PM.png

package.json:

Screen Shot 2019-11-08 at 7.09.29 PM.png

Server.js file Where we will be starting our development server

Screen Shot 2019-11-08 at 6.14.15 PM.png

helper.js file where will have our upload (helper) function

Screen Shot 2019-11-08 at 6.41.40 PM.png

Now let create a user folder where we will have Our user.controller.js, user.model.js and user.route.js

user.model.js

Screen Shot 2019-11-08 at 6.50.07 PM.png

user.controller.js

Screen Shot 2019-11-08 at 6.46.00 PM.png

Screen Shot 2019-11-08 at 6.46.25 PM.png

find all created user:

Screen Shot 2019-11-08 at 6.49.00 PM.png

user.route.js

Screen Shot 2019-11-08 at 6.51.55 PM.png

Now let test our endpoints:

create endpoint:

Screen Shot 2019-11-08 at 6.54.30 PM.png find endpoint:

Screen Shot 2019-11-08 at 6.55.34 PM.png

Click Here to Get source code