Configuring Express Multer Middleware and Checking File Information
Published in
5 min readMar 16, 2020
Multer is a middleware that lets us process file uploads with our Express app.
In this article, we’ll look at the settings that we can change to upload files our way, and also check the file information.
Checking File Information
We can check the uploaded files’ information by looking at the req.file
object for single file upload and the array entries of req.files
for multiple file uploads.
These fields are available for each file:
fieldname
— field name specified in the formoriginalname
— name of the file on the user’s computerencoding
— encoding type of the filemimetype
— MIME-type of the filesize
— size of the file in bytesdestination
— the folder where the file was saved on the serverfilename
— name of the file stored in thedestination
path
— the full path of the uploaded filebuffer
—Buffer
object of the whole file
Options for File Upload
The multer
function takes an options
object that takes a variety of options.