Menu

1 / 2

Storing Uploaded Files and Serving Them in Express

DEV Community·Shivam Yadav·6 months ago
#5l7htANY
#now#how#first#part#understanding
Reading 0:00
15s threshold

yooo its me shivam

and today we are doing to talk about file uploads yessss

it might sound a piece of shit topic but it is hard okay so lets start 😭

first lets start with frontend and backend flow

frontend send the file to the backend

backend receives

thing to be handled:

taking the data properly (and when i say data i mean file)

after that store them properly

and in the end serve that data to the user properly

okay this is the main goal

first let understand one thing

and that is how the data will come from frontend to backend

Normal HTTP requests usually send:

{ "name" : "shivam" }

Enter fullscreen mode

Exit fullscreen mode

This is easy.

But files are NOT text.

A PNG file is raw binary bytes:

89 50 4E 47 ...

Enter fullscreen mode

Exit fullscreen mode

So browsers needed a special way to send everything in proper way:

text

files

metadata

all together in ONE request.

and that will be done using:

multipart/form-data

why called multipart?

because it contain multi form data 😭

yes…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.