Serving Video Files and Images using node.js and mongoDB


I have a question, if we want to serve a video on our website, then where do the video files or images live? is it on the server or we need to upload them in the database?


Images sometimes go in a database. They’re normally quite big, so as a rule people tend to avoid that: they are stored somewhere, and a database will hold information about them (for example a URL pointing to where they are stored). There are certain advantages to them being actually stored in a database instead, but size often precludes this, it’s a trade-off (ease of querying them because everything is in one place vs. having to store big blobs of stuff).

Videos files are really big, as a rule it’s not really practical to store them in a database.

1 Like

I am currently on streaming type sites, and here is my upcoming plan:

When the user uploads a video file I am gonna save it on the server (or a storage bucket somewhere), then encode it, then send it back to the users.

If you google streaming video in nodejs, you will find some code snippets, and see which one suits your need.

1 Like

@razzakammar_nano can you please give me a guide on how to do it, im new in back-end development and im on my way in learning it. Therefore, the road was still unclear for me. I’ve seen a lot of articles advicing similar with that and probably i will implement that also…

Thanks in advance…