DEV Community

0 seconds of 19 minutes, 45 secondsVolume 90%
Press shift question mark to access a list of keyboard shortcuts
00:00
00:00
19:45
 
James Bubb
James Bubb

Posted on

2 1

How to upload files with Node.js

Originally published here on YouTube.
(Please give me a thumbs up and subscribe if you found this useful 🙏).

Also, part 2 of this tutorial is available here.

Get a copy of the code here: https://github.com/codebubb/tutorial-nodejs-file-upload

Docs for the Node.js multer npm package: https://www.npmjs.com/package/multer

Docs for the Node.js multer-s3 npm package:
https://www.npmjs.com/package/multer-s3

How To Upload Files With Node.js

00:00 Introduction
00:17 Setting up
04:00 Uploading to a private server
04:50 Using multer
06:28 Customising uploaded filename
09:25 Uploading multiple files
15:41 Creating an S3 bucket
16:12 Getting AWS Access Credentials
19:06 Summary

— Follow Me —
Twitter: https://www.twitter.com/codebubb
Facebook: https://www.facebook.com/juniordevelopercentral/
Blog: https://www.juniordevelopercentral.com/
— Thanks! —

So in this Node.js tutorial, we're going to take a look at how to upload files with Node.js.

To start off with we'll install the necessary dependencies (express & multer mainly) to handle the receipt and processing of files uploaded. But before we start setting up our Node.js code, we'll create a simple HTML form that can deliver the files submitted to us via the user in a web browser.

With the form setup, we'll take a simple example of the Node js multer package will is easy to configure if we just want to upload a simple file. Then we'll see how we can use multer with express inside our Node js application to customise how the file is named when it is stored.

To round off our first section, we'll look at how to upload multiple files with Node.js at the same time.

Once we've got a working version that will upload files with Node.js on a private server, we'll move on to working with uploading to the AWS S3 service.

You'll see how you need to use the aws-sdk and multer-s3 packages to configure the processing of your uploads. Once the code is written, i'll show you how to create a new bucket in S3 and also download the necessary credentials to enable the aws-sdk to successfully upload your files to S3.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (1)

Collapse
 
sherwinwater profile image
Shuwen

Thank you!

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up