Creating the image upload server
We have finished building the services. Now let's build the image storage server. The image storage server defines the routes using which an image can be stored, deleted, or retrieved.
Open the Initial/image-storage
directory. Inside the directory, you will find a package.json
file and an app.js
file. The app.js
file is where you will write the code, and package.json
lists the dependencies for the image storage server. The upload service is dependent on express
, connect-multiparty
, path
, and fs
. Run the npm install
command inside Initial/image-storage
to install the dependencies locally.
The following is the code to import the modules:
var express = require("express"); var app = express(); var fs = require("fs"); var multipart = require("connect-multiparty")();
Now let's define the route using which the upload service can store images in the image storage server. The upload service makes the POST request to the /store
...