FILE STORAGE / LESSON 01
What Is File Storage?
Why uploads and images don't belong in your database or on your server, and how object storage works

Loading the lesson…
Loading activities…
FILE STORAGE / LESSON 01
Why uploads and images don't belong in your database or on your server, and how object storage works

Loading the lesson…
Loading activities…
Profile pictures, PDFs, videos, product photos. Sooner or later your app has to hang on to files that people upload, and they have to live SOMEWHERE. I built a lil Bulk Image Processor that chews through 100 images in about 5 minutes... and every one of those images needs a home when it's done. This lesson covers where files should live, why, and what to look for in a file storage service.
A database is great at small, tidy pieces of information. A name, an email address, an order total. It was never built to hold a 20 MB video.
So you might think, fine, I'll just save uploads to my server's disk. That falls apart fast too.
So apps split the job. Files go to a storage service, and the database keeps a small record that points to each file.
Most file storage services use a model called object storage. Three words and you've got it.
avatars/user-123.png. It looks like a folder path, but it's honestly just a name.You put objects in with an API call and get them back by key, or through a URL.
They choose a photo on your upload page.
Either your server uploads it, or your server hands the browser a short-lived link so it can upload straight to storage.
The file lands in your bucket under a key.
You save the key or URL right next to the user's record.
When the page loads, it uses that URL to display the image.
Not every file should be visible to the whole world. A product photo can be public. An invoice or somebody's ID document absolutely can't.
Storage services let you keep a bucket private and hand out temporary links when someone's allowed to see a file. You'll set that up in the R2 chapter.
When you're comparing file storage services, ask yourself these questions.
This module covers Cloudflare R2, an object storage service that works with the S3 API. Its chapter walks through how R2 works, how to set up and lock down a bucket, and then how to upload files from code.
Next up is the Cloudflare R2 chapter, where you'll see object storage doing its thing for real...