Skip to content
AI-powered appsNewChat, vision, voice, generationBookings & schedulingAppointments that book themselvesShops & sellingA storefront in every pocketClient & businessRun the operation from one placeCommunities & clubsA home that is not a group chat
Health & wellnessHabits, tracking and calmGames2D, 3D and multiplayerPersonal & toolsThe tool you wish existedInternal toolsThe tool ops never had time for
See all use cases
ArcadeNewPricingSecurity
EngineThe game engine and World EditorHow it worksFrom one sentence to a live productDocsGuides for building and publishingBlogStories, guides and newsChangelogWhat shipped latelyStatusUptime of every serviceSupportGet help from the team
AI-powered appsBookings & schedulingShops & sellingClient & businessCommunities & clubsHealth & wellnessGamesPersonal & toolsInternal tools
See all use cases
ArcadeNewPricingSecurity
EngineHow it worksDocsBlogChangelogStatusSupport
Language
Blog
BackendNovember 22, 20265 min read

How Apps Store Files and Images

Files do not go in the database. They go in storage buckets, and the database keeps a pointer. Here is how uploads, privacy and image sizes work in a real app.

Startbase Team
Editorial ink illustration of a wall of wooden post office boxes with one open box holding a rolled photograph, the rolled photograph in ember orange

Key takeaways

  • Files live in object storage, grouped in buckets. The database stores only each file's path and a few facts about it.
  • Public buckets serve files to anyone with the URL; private buckets need permission rules or short-lived signed URLs.
  • Resize images before or after upload, cap file sizes, and name files so one user cannot overwrite another's.

Apps store files and images in object storage: a service built to hold large files cheaply and serve them quickly, organized into containers called buckets. The database does not hold the photo itself. It holds a short path such as `avatars/u_481/profile.webp`, and the app turns that path into a URL when it needs to show the image. Access rules on the bucket decide who can upload, see or delete each file.

Why files do not go in the database

Databases are built for many small, structured facts that are searched and joined constantly. Files are the opposite: large, opaque blobs that are read whole. Stuffing a 4 MB photo into a table row makes backups huge, queries slow and costs higher. Object storage is designed for exactly this job, and it can sit behind a CDN, a network of servers around the world that keeps copies of popular files close to viewers.

The pattern is the same in almost every app. A `listings` table in a rental app has a `photos` relation; each photo row stores `listing_id`, `path`, `width`, `height` and `uploaded_by`. The actual JPEG sits in a `listing-photos` bucket. Delete the listing and you delete the rows and the files together.

Buckets, paths and file names

A bucket is like a top-level folder with its own access rules. Most apps need two to four: `avatars`, `attachments`, maybe `public-assets` for marketing images. Inside a bucket, folders are really just parts of the path.

  • Put the owner's ID in the path: `attachments/<user_id>/<file>`. Access rules can then say "users may write only inside their own folder", which is simple to check.
  • Never trust the uploaded file name. Two people upload `IMG_0001.jpg`; one overwrites the other. Generate a unique name (a random ID) and keep the original name in the database if you want to show it.
  • Keep the extension honest. Check the file type on upload. A file called `photo.jpg` can contain anything.

Public files, private files and signed URLs

This is the decision that matters most. A public bucket serves any file to anyone who has its URL, with no sign-in. That is right for product photos in a shop or avatars on a public forum. It is wrong for invoices, ID documents, medical notes or a private journal's pictures, because URLs leak: they get pasted into chats, saved in browser history and forwarded.

A private bucket refuses anonymous requests. Signed-in users reach files only if the bucket's rules allow them, and to share one file temporarily you create a signed URL: a link with a cryptographic signature and an expiry built in. Send a client their contract as a signed URL valid for an hour and the link is useless the next day.

Tip

Default every new bucket to private and make one public only when you can say out loud why strangers should be able to see every file in it.

Images need more than one size

Phone cameras produce photos of several megabytes. Showing a 4,000-pixel photo as a 64-pixel avatar wastes the user's data and slows your page. Three habits fix most image problems:

  1. 01Resize on upload or on delivery. Keep the original if you need it, but serve a thumbnail (around 200 pixels), a medium size for feeds and a large size for full-screen views. Some storage services can resize on request; otherwise resize in the browser before uploading or in a server function after.
  2. 02Use modern formats. WebP and AVIF are much smaller than JPEG or PNG at similar quality and work in current browsers.
  3. 03Strip location data. Photos from phones often carry GPS coordinates in their metadata. For user-uploaded images that will be shown to others, remove it.

A safe upload, step by step

Here is a sensible flow for a "add a photo to your listing" button:

  1. 01The browser checks type and size first (images only, under 10 MB) so users get an instant, friendly error.
  2. 02It resizes the image and uploads it to `listing-photos/<user_id>/<random-id>.webp` with the user's session.
  3. 03The bucket's rules confirm the user is signed in and writing inside their own folder. The browser check was a courtesy; this one is the real one.
  4. 04The app inserts a row in `listing_photos` with the path and dimensions, which row level security ties to a listing the user owns.
  5. 05On delete, the app removes the row and the file, so storage does not fill with orphans.

Large files and video

Photos and PDFs are easy. Large files and video need more planning:

  • Resumable uploads: a 500 MB file over a phone connection will drop at some point. Upload methods that send the file in chunks can resume where they stopped instead of starting over.
  • Video needs processing: phones record in formats and bitrates that do not stream well to every device. Video platforms convert uploads into several sizes and stream them adaptively. For a few short clips, plain storage works; for a video-heavy product, a dedicated video service is usually worth it.
  • Bandwidth costs more than storage: keeping a file is cheap; serving it thousands of times is what adds up. Caching through a CDN and serving smaller versions keeps the bill sane.

Decide early how long you keep things. A meme app that keeps every upload forever pays for every upload forever. A rule like "drafts disappear after 30 days" is easy to promise at launch and hard to add later.

File storage in a Startbase app

Startbase Cloud includes Supabase Storage, managed from the Storage section of the Backend tab. Files are organized in buckets, and new buckets are always private. Making a bucket public asks you to confirm first, because anyone with a file's URL could then read it. For private buckets you can generate signed URLs valid for one hour to share individual files. You can upload several files at once (uploads in the Backend tab are capped at 15 MB per file; for bigger files, ask the agent to upload from the workspace), create folders, and move or copy a file by giving it a new path. Deleting a bucket removes everything in it and cannot be undone. The storage docs have the details.

Let tenants upload photos of maintenance problems in my property app. Store them in a private bucket under each tenant's user ID, images only, max 8 MB, resized to 1,600 pixels wide as WebP with location data removed. Tenants see only their own photos; the landlord sees photos for their properties through signed links. Deleting a request deletes its photos.

Storage costs grow with what you keep and what you serve, so build cleanup in from the start. For how files fit next to tables and login, read database basics and row-level security explained, since bucket rules follow the same logic.

Frequently asked questions

Should I store images in my database?

No. Store the file in object storage and save its path, size and owner in the database. It keeps the database small, backups fast and images quick to serve.

What is a storage bucket?

A named container in object storage, like a top-level folder, with its own access rules. Apps typically have a few, such as avatars and attachments.

What is a signed URL?

A link to a private file that includes a signature and an expiry time. Anyone holding it can open the file until it expires, after which the link stops working.

How big should I let uploads be?

As small as your feature allows. A few megabytes is plenty for photos once resized. Set a clear limit, check it in the browser for a friendly message, and enforce it on the server.

On this page

  • Why files do not go in the database
  • Buckets, paths and file names
  • Public files, private files and signed URLs
  • Images need more than one size
  • A safe upload, step by step
  • Large files and video
  • File storage in a Startbase app

Keep reading

More in Backend
Editorial ink illustration of a shop counter with a brass cash register and a curling paper receipt, the receipt in ember orange
BackendNovember 22, 2026

How to Accept Payments in Your App with Stripe

Taking money online is mostly a solved problem, if you let Stripe hold the card and you trust only its webhook. Here is the flow, the data you store and the mistakes to avoid.

5 min read
Editorial ink illustration of an iron safe set into a workshop wall with a key hanging on a hook beside it, the key in ember orange
BackendNovember 22, 2026

API Keys and Secrets: Keeping Them Safe

Anything you ship to a browser or phone can be read. Here is how to tell a public key from a secret one, where secrets belong, and the five-step plan for a leaked key.

5 min read

Read less. Ship more.

Everything in this post is one prompt away. Describe your app and watch it build.

Start building

Apps, games, backends and publishing from one conversation.

Product

  • Features
  • Use cases
  • Pricing
  • Changelog

Resources

  • Blog
  • Docs
  • Support
  • Status
  • Security

Contact

  • w@startbase.ai
  • X / Twitter
  • LinkedIn
  • Instagram

Legal

  • Terms
  • Privacy

© 2026 Startbase. All rights reserved.