Better Programming

Advice for programmers.

Follow publication

Member-only story

NestJS File Uploading Using Multer

Gabriel Tanner
Better Programming
Published in
5 min readAug 27, 2019
Photo by JF Martin on Unsplash

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

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Gabriel Tanner
Gabriel Tanner

Written by Gabriel Tanner

Android Developer | Web Developer | Part-time Blogger | Catch me at https://gabrieltanner.org/ | Buy me a coffee buymeacoff.ee/gabrieltanner

Write a response