Member-only story
NestJS File Uploading Using Multer
How to develop a simple file-uploading app
This guide will show you how you can implement file uploading into your NestJS application and the things you should keep in mind when doing so. You will develop an application with three endpoints that will do the following:
- Upload an image;
- Upload multiple images;
- Get the image using the image path.
You will also add custom utilities to edit the file name and validate the file upload for images.
So without wasting any further time, let’s get into it.
Setup
The first thing you need to do is create a NestJS project that will hold our fileserver. For that, you need to open your terminal and run the following command:
nest new nest-file-uploading && cd nest-file-uploading
This creates a new directory called nest-file-uploading
and initializes it with a standard NestJS configuration.
With the directory in place, you can go ahead and install the needed dependencies for the application using the following commands:
npm install @nestjs/platform-express --save
npm install @types/express -D