You can then pass around the
uploadService object to other modules that use it.

1

functionFileUploadRoute(express,uploadService){

To read uploads in a route, add it to the second parameter of the route definition. The following commands processes a single file uploaded under
file attribute within post form-data.

1

2

3

router.post("/",uploadService.single('file'),function(req,res){

varuploadedFile=req.file;

});

The
uploadedFile object here contains data about the file that was uploaded. The
buffer attribute of this object contains the actual file content. The object also has other attributes like
filename,
mimeType and encoding that can be used to process the file according its type.