Cloud Storage for Firebase in Google Cloud

Cloud Storage for Firebase in Google Cloud

A beginner-friendly guide to letting your mobile and web app users upload and download photos, videos, and files safely, without you building a file server.

Think about the apps on your phone. You post a profile picture. You send a voice note. You attach a PDF to a support request. Every one of those actions means a file leaves your phone and lands somewhere safe on the internet, and later another person’s phone fetches it back.

Somebody has to build the “somewhere safe”. Doing it from scratch is hard: you need huge storage, fast delivery, protection against strangers, and a way to keep going when the phone loses signal in a lift. Cloud Storage for Firebase gives you all of this ready-made. This guide explains it from zero, in simple words, with an everyday analogy for each big idea.

1What Is Cloud Storage for Firebase?

First we meet the three names that are mixed together in the title.

Google Cloud, Firebase, and Cloud Storage

  • Google Cloud is Google’s big collection of internet services for storing data, running programs, and more.
  • Firebase is a set of tools built on top of Google Cloud that helps developers make mobile and web apps quickly. It includes sign-in, databases, hosting, analytics, and more.
  • Cloud Storage is Google Cloud’s service for keeping huge numbers of files, called objects, in containers called buckets.

Cloud Storage for Firebase is Cloud Storage with a friendly front door made for app developers. Your app uses a simple Firebase library, called an SDK (software development kit), to send and fetch files directly from the user’s device. The files land in a real Google Cloud Storage bucket behind the scenes.

Analogy

Cloud Storage is a giant bank vault with safe-deposit boxes. Firebase adds a friendly bank teller at the front desk who checks each customer’s ID, knows which boxes they may open, and helps carry the boxes in and out. Customers never walk into the vault alone.

What it gives you

Direct

Device to storage

Files go straight from the phone or browser to the bucket, with no server of yours in the middle.

Reliable

Robust transfers

Uploads and downloads can pause, resume, and retry after the network drops.

Secure

Rules and sign-in

Security Rules decide who can read or write each file, using the user’s Firebase sign-in.

Scalable

Built on Google Cloud

The same storage system that handles huge companies handles your app as it grows.

i
Good to know

Firebase plans, bucket setup rules, free allowances, and limits have changed over time. This guide teaches the ideas. Always check the current Firebase and Google Cloud pages for exact numbers and plan requirements before you launch.

2Why Does It Exist?

The problem it solves for app builders.

The hard way to handle user files

Imagine you are building a photo-sharing app without this service. A user taps “upload”. Your app must send the photo to your own server. Your server must check who the user is, check the file is safe, save it on a disk, and later send it back to anyone who asks.

Now picture a million users at once. Your server needs to handle big files, slow connections, and attackers who try to fill your disk with junk. Your server becomes a busy, expensive bottleneck.

The Firebase way

With Cloud Storage for Firebase, the phone talks straight to Google’s storage. Your server is not in the path of each upload. Security is decided by rules you write once, and Google’s global systems carry the traffic.

flowchart LR
  subgraph Hard["The hard way"]
    A1["Phone"] --> S1["Your own file server"]
    S1 --> D1["Your disks"]
  end
  subgraph Easy["With Firebase"]
    A2["Phone with Firebase SDK"] --> B2["Cloud Storage bucket"]
    A2 --> R2["Security Rules check access"]
  end
    
Figure 1 — Your own file server versus talking directly to managed storage
Analogy

The hard way is like asking every guest to hand their coat to you personally, and you walk each coat to a cupboard. The Firebase way is a coat-check desk run by professionals, with a numbered ticket for each guest. You just decide who is allowed to use the desk.

3Core Concepts You Must Know

Learn these words and everything else becomes easy to follow.

Bucket

A bucket is the top-level container that holds your files. Every Firebase project that uses storage has a default bucket, and you can add more. A bucket has a name, a location, and settings. Its location is chosen when you create it and generally cannot be changed later, so pick it with care.

Object

An object is one stored file together with its information. Photos, videos, audio, PDFs, and text files are all objects. Every object has a path-like name, such as “users/anita/profile.jpg”.

Folders are an illusion

Cloud Storage does not have real folders. The slashes in a name are just part of the name. The console and the SDKs show them as folders to make life easy, but really they are long file names with slashes in them. This detail matters later when you rename or list things.

Analogy

Imagine a huge wall of lockers, each with a long label like “users/anita/profile.jpg”. There are no rooms inside the wall, only labels. Your eyes group labels that start the same, so it looks like folders, but each locker is separate.

Reference

In the Firebase SDK, a reference is a pointer to a location in your bucket. You create a reference from the storage service, then use “child” to go deeper. A reference is just an address. Making one does not touch the network. Only when you upload, download, or delete does your app actually talk to the service.

Metadata

Metadata is information about a file: its size, its content type (such as image or video), when it was created, and custom labels you add yourself. Security Rules can look at metadata to make decisions.

Download URL

A download URL is a long web address that lets anyone who has it fetch a file. It contains a secret token. Think of it as a “share link”. Apps often store this address in a database and use it to show images.

Security Rules

Firebase Security Rules for Cloud Storage are a small set of instructions you write that say who may read or write which files. They run on Google’s side, so users cannot skip them.

?
Remember

Bucket holds objects. A reference is an address of an object. Metadata describes it. A download URL shares it. Security Rules guard it.

4Architecture and Components

How the pieces connect from the user’s phone to the stored bytes.

The main pieces

  • Client app: your iOS, Android, web, Flutter, or game app, using the Firebase Storage SDK.
  • Firebase Authentication: tells the system who the signed-in user is.
  • Security Rules: check each request against your rules.
  • Firebase App Check: an optional guard that helps prove the request came from your real app, not a copy or a bot.
  • The bucket: a Google Cloud Storage bucket where the files really live.
  • Cloud Functions or server code: optional backend code that reacts when files arrive or change.
  • Admin tools: the Google Cloud console and the server-side Admin SDK for managing files with higher power.
flowchart TD
  APP["Client app with Firebase SDK"] --> AUTH["Firebase Authentication: who is the user?"]
  APP --> AC["App Check: is this my real app?"]
  APP --> RULES["Security Rules: is this allowed?"]
  RULES --> BKT["Cloud Storage bucket"]
  BKT --> CF["Cloud Functions: react to new files"]
  CF --> DB["Database or other services"]
  ADM["Server code with Admin SDK"] --> BKT
    
Figure 2 — The main building blocks of Cloud Storage for Firebase
Analogy

Picture a concert. Authentication is the ticket scanner who knows your name. App Check is the person who confirms your ticket is not a photocopy. Security Rules are the signs that say which sections you may enter. The bucket is the stadium itself, and Cloud Functions are the staff who tidy up after each act.

Two doors to the same bucket

The same bucket can be reached in two ways. The first is the Firebase door, used by client apps. This door always applies your Security Rules. The second is the Google Cloud door, used by server programs and tools. This one is controlled by IAM (Identity and Access Management) permissions instead. Server code using the Admin SDK has special trusted access and skips Security Rules, so it must be written carefully and kept on a safe server, never inside an app.

5How an Upload Works Internally

Follow one photo from a phone to the bucket.

1

User signs in

The user logs in with Firebase Authentication. The SDK now carries a secure identity token on every request.

2

The app builds a reference

The app chooses the path, such as “users/anita/profile.jpg”, and prepares the file and its metadata.

3

The SDK starts the upload

The SDK sends the file to Cloud Storage. Big files are split into pieces so progress is saved as it goes.

4

Security Rules decide

Google checks the identity, the path, the size, and the file type against your rules. If any check fails, the upload is refused.

5

The object is stored

The file is written to the bucket and copied across disks for safety. Metadata is saved with it.

6

Follow-up actions

The app can ask for the download URL. A Cloud Function can wake up to make a thumbnail or update a database.

sequenceDiagram
  participant U as User phone
  participant SDK as Firebase SDK
  participant R as Security Rules
  participant B as Cloud Storage bucket
  participant F as Cloud Function
  U->>SDK: Choose photo to upload
  SDK->>R: Upload request with identity token
  R-->>SDK: Allowed
  SDK->>B: Send file in pieces
  B-->>SDK: Stored, return metadata
  B->>F: New object event
  F->>B: Create small thumbnail
  SDK-->>U: Upload complete
    
Figure 3 — A full upload with a follow-up thumbnail function

Pause, resume, and cancel

Mobile networks are unreliable. The SDK tracks how much of a file has been uploaded, so if the connection drops, it can continue from where it stopped rather than starting again. Your app can also let the user pause, resume, or cancel. It can also watch the progress to show a progress bar.

Ways to send data

The SDK can upload from a file on the device, from a raw block of bytes in memory, from text, or from a stream of data. Choose whichever fits what your app has at hand.

6Downloading and Sharing Files

Three common ways to get a file back to a screen.

1. Download URL

The app asks the SDK for a download URL, then gives it to an image view or a video player. Anyone who holds this URL can open the file, even without signing in. That makes it easy to use, but you must treat these URLs like passwords for that single file. You can revoke the token from the console if a link leaks.

2. Direct download through the SDK

The app can download the bytes into memory or into a local file. The SDK applies Security Rules to this request, so the user must be allowed to read it. This is the better choice for private files.

3. Server-created signed links

Your server code can create a signed URL, which is a link that works only for a limited time and only for a specific file. After the time ends, the link stops working. This is useful for paid content or private documents.

Analogy

A download URL is a hotel key card that anyone can use if they find it. A direct SDK download is a receptionist who checks your ID each time. A signed URL is a day pass that expires at midnight.

Listing and deleting

The SDK can list files under a reference, which helps build a gallery of a user’s uploads. It can also delete a file or update its metadata, as long as your rules allow those actions. Because folders are only name prefixes, “deleting a folder” really means deleting each file whose name starts with that prefix.

!
Watch out

Never store private files and then rely only on a secret-looking file name. Secret names are not security. Use Security Rules and expiring links for anything that must stay private.

7Security Rules in Depth

The most important chapter. Rules are what keep strangers out.

What rules can look at

A rule can check many facts about a request. It can see whether the user is signed in, and which user it is. It can see the file path. It can see the size of an incoming file and its content type. It can see the metadata of an existing file. It can even look at a custom claim on the user’s account, such as “is an administrator”.

Typical rule ideas, in plain words

  • Anyone may read files in the public images area, but nobody may write there from the app.
  • A signed-in user may read and write only files inside a folder named with their own user number.
  • A user may upload only if the file is an image and smaller than a few megabytes.
  • Only users marked as moderators may delete files from the shared area.
flowchart TD
  REQ["Incoming request"] --> SIGN{"Signed in?"}
  SIGN -- "No" --> PUB{"Is path public for reading?"}
  PUB -- "Yes and read only" --> OK["Allowed"]
  PUB -- "No" --> DENY["Denied"]
  SIGN -- "Yes" --> OWN{"Is path inside user's own area?"}
  OWN -- "No" --> DENY
  OWN -- "Yes" --> SIZE{"Size and type acceptable?"}
  SIZE -- "Yes" --> OK
  SIZE -- "No" --> DENY
    
Figure 4 — How a typical set of rules makes a decision
Analogy

Rules are the instructions you give a nightclub doorman: “Let in anyone over 18 with ID, but only the VIP list goes upstairs, and nobody brings in glass bottles.” The doorman applies those rules to every single person without exception.

Test mode versus locked mode

When you begin a project, the console may offer a quick “test” setup that allows open access for a limited period, to make learning easy. Open access is dangerous in a real product. Anyone on the internet could read, overwrite, or fill your bucket and run up your bill. Replace any open rules with real rules before you share your app.

Testing rules

Firebase offers a rules simulator in the console and a local emulator for your computer. Use them to try pretend requests and confirm that allowed users get in and strangers do not. Treat every change to rules like a change to the front door lock: test it first.

!
Security rule of thumb

Start from “deny everything” and then open exactly what the app needs, no more. It is much safer than starting open and trying to close gaps.

8Authentication, App Check, and Abuse Protection

Knowing who the user is, and that the app is real.

Firebase Authentication

Firebase Authentication lets users sign in with an email, a phone number, or accounts from big providers. Once signed in, every Storage request carries proof of identity. Your rules can then say “this file belongs to that user”.

Firebase App Check

Rules check the user. App Check checks the app. It asks the phone or browser to prove, using the operating system’s own tools, that the request comes from your genuine, unmodified app. Requests from scripts, copied apps, or bots can be blocked even if they hold a valid user token.

Analogy

Authentication checks the passenger’s passport. App Check checks that the aircraft really belongs to the airline. You want both before letting anyone take off with your cargo.

Cost and abuse control

An attacker who finds an open bucket can upload huge amounts of data or download your files again and again. Both cost you money. Protect yourself with strict size and type limits in rules, App Check, billing alerts, and budget notifications in Google Cloud. Consider shorter retention, so junk is deleted automatically.

9Reacting to Files with Cloud Functions

Turning uploads into automatic actions.

Storage triggers

A Cloud Function is a small piece of your server code that runs only when something happens, and you pay only while it runs. A storage trigger wakes your function when a file is created, deleted, archived, or when its metadata changes.

Popular uses

Media

Make thumbnails

When a big photo lands, create small and medium copies for fast display.

Safety

Scan content

Check uploads for harmful files or unsafe images, and remove the bad ones.

Data

Update a database

Write the file’s address into a user’s profile record automatically.

Cleanup

Tidy up

When a user deletes their account, remove all of their files.

AI

Analyze

Send a new image or audio file to a machine-learning service for labels or text.

Notify

Tell people

Send a push message when a shared file is ready.

i
Tip

Firebase also offers ready-made Extensions, such as one that resizes images. They save you from writing common functions yourself. Check the current Extensions catalog to see what is available.

!
Avoid a loop

If your function writes a new file into the same place that triggers it, it can trigger itself again and again. Write results to a different path, or check for your own output before acting.

10Buckets, Locations, and Storage Classes

Setting up the foundation correctly.

Choosing a location

A bucket lives in a single region, a pair of regions, or a large multi-region area. Pick a place near most of your users and near your other services, such as your database and Cloud Functions. Close places mean faster transfers and lower network charges. Because the location usually cannot be changed later, decide before you create it.

Storage classes

A storage class is a price and access plan for files.

Class ideaBest forTrade-off
StandardFiles used often, such as app imagesHighest storage price per month, lowest access price
NearlineFiles read about once a monthCheaper to keep, small fee to read
ColdlineFiles read a few times a yearEven cheaper to keep, higher read fee
ArchiveLong-term records you hardly ever openCheapest to keep, highest read fee and minimum keep time
Analogy

Standard is the shelf by your front door, where your keys sit. Nearline is the hall cupboard. Coldline is the attic. Archive is the storage unit across town. The farther it is, the cheaper the space, but the longer and costlier the trip to fetch things.

Lifecycle rules and versioning

Using the Google Cloud console, you can create lifecycle rules that act on files automatically. For example, “move files to a colder class after 90 days” or “delete temporary uploads after 7 days”. You can also turn on object versioning so that older copies are kept when a file is overwritten, which helps recover from mistakes at the price of extra storage.

11Performance, Reliability, and Web Setup

Keeping transfers quick and dependable.

Performance tips

  • Resize before uploading. A phone photo can be many megabytes. Shrinking it on the device saves time, data, and money.
  • Serve small versions. Show thumbnails in lists and load the full image only when needed.
  • Use caching. Set cache settings in metadata so browsers and phones keep files rather than fetching them over and over.
  • Choose a nearby location for your bucket.
  • Compress text-like files, and use modern image and video formats.

Reliability

Cloud Storage keeps multiple copies of every object, so a single disk or machine failure does not lose your data. Multi-region and dual-region buckets keep copies in separate locations for even stronger protection. The SDK’s retry logic helps with short outages of the user’s network, and it gives up after a time limit that you can adjust.

Offline behavior

Unlike some Firebase databases, Cloud Storage does not keep a full offline queue for you. If a user is offline, the upload will wait and retry for a while, then fail. Your app should handle this by showing a friendly message and letting the user try again.

Web apps and CORS

Browsers have a safety rule called CORS (cross-origin resource sharing). It stops a web page on one site from freely reading files from another site. If your website needs to fetch files from the bucket in certain ways, you must tell the bucket which sites are allowed through a CORS setting.

Analogy

CORS is like a building’s guest list kept by the front desk. A visitor from another company is turned away unless their company name is on the list.

12Monitoring, Logging, and Cost

Seeing what happens and what it costs.

Monitoring

The Firebase console shows simple usage charts, such as how much is stored and how much data was downloaded. For deeper views, Google Cloud’s monitoring tools show request counts, errors, and delays. You can set alerts when numbers jump unexpectedly.

Logging

Audit logs record administrative actions such as changing permissions or deleting a bucket. Access logs for object reads and writes can be turned on in Google Cloud for investigations, though they add some cost. Rules denials appear in the Firebase tools to help you debug blocked requests.

What you pay for

  • Stored data: the amount of data kept, per month, depending on class and location.
  • Network downloads: data leaving Google Cloud to users on the internet.
  • Operations: the number of reads, writes, and list calls.
  • Extras: replication across regions and early deletion of cold storage files.

Firebase has offered a free allowance on its entry plan, but the rules about which plan is needed for storage have changed over time. Confirm the current pricing page and plan requirements before you depend on a free tier.

Ways to save

  • Compress and resize on the device before upload.
  • Use lifecycle rules to delete temporary files and to move old ones to cold classes.
  • Cache aggressively, so repeated downloads are rarer.
  • Set budgets and alerts on your Google Cloud billing account.
  • Block abuse with App Check and strict rules.
i
Tip

Set a budget alert on day one, even a small one. A bug that downloads the same large video in a loop can turn into a surprise bill within hours.

13Advantages, Disadvantages, and Trade-offs

An honest report card.

Advantages

  • Very quick to add to an app with the SDK
  • No server needed in the upload path
  • Resumable and retrying transfers
  • Works well with Firebase Authentication and App Check
  • Powered by Google Cloud Storage scale and durability
  • Easy event triggers for automation

Disadvantages

  • Security depends on you writing rules correctly
  • No true folders, so renaming and moving are really copy and delete
  • Download links can be shared by anyone who holds them
  • No built-in image editing; you add functions or extensions
  • Costs can grow with heavy downloads
  • Tied to Google Cloud and Firebase tools

Compared with its neighbors

OptionBest forNotes
Cloud Storage for FirebaseFiles uploaded and downloaded straight from appsUses Firebase sign-in and Security Rules
Plain Cloud Storage with server codeBack-end systems, data pipelines, and large internal dataControlled mainly through IAM
Firestore or Realtime DatabaseStructured data such as names, posts, and messagesNot meant for large files; store the file in Storage and its address in the database
FilestoreShared folders for servers using NFSNot designed for phone apps
Firebase HostingWebsite pages and static assetsGreat for your site files, not for user uploads
Store the file in Storage. Store the file’s address in the database.

14Design Patterns and Anti-patterns

Habits to copy, and traps to avoid.

Good patterns

Pattern

User-owned folders

Store each user’s files under their own user number, and write rules that match it.

Pattern

Database pointer

Keep the file’s path in a database record so the app can find it fast.

Pattern

Unique file names

Add a random id to file names so two users never overwrite each other.

Pattern

Upload then process

Let a Cloud Function make thumbnails and scans after upload, away from the user’s phone.

Pattern

Separate buckets

Use one bucket for public content and another for private, with different rules and settings.

Pattern

Temporary area

Send fresh uploads to a staging path and auto-delete anything that is never approved.

flowchart LR
  P["User phone"] --> ST["Staging path in bucket"]
  ST --> CF["Cloud Function: scan and resize"]
  CF -- "Safe" --> PUBP["Approved path in bucket"]
  CF -- "Unsafe" --> DEL["Delete file"]
  PUBP --> DB["Database record holds file path"]
  DB --> APP["App shows the image"]
    
Figure 5 — A safe upload pipeline with a staging area

Anti-patterns

ANTI-PATTERN 01Avoid
What people do

They leave test-mode open rules in place after launch.

Why it hurts

Anyone can read, overwrite, or flood the bucket, and you pay for it.

Do this instead

Write strict rules, test them with the simulator, and set budget alerts.

ANTI-PATTERN 02Avoid
What people do

They put admin keys or service account files inside the mobile app.

Why it hurts

Anyone can extract them from the app and gain full control, skipping all rules.

Do this instead

Keep powerful credentials on a server and give apps only the normal client SDK.

ANTI-PATTERN 03Avoid
What people do

They upload full-size camera photos and show them directly in a list.

Why it hurts

Screens load slowly, data plans burn, and download costs rise.

Do this instead

Resize before uploading and display small thumbnails in lists.

15Best Practices, Common Mistakes, and Real-World Uses

Your checklist, the usual stumbles, and where this shines.

Best practices

  • Plan your path layout before writing code, so rules stay simple.
  • Lock rules down from day one and test them with the emulator.
  • Turn on App Check to reduce abuse by fake clients.
  • Limit file size and type in rules for every upload path.
  • Choose the bucket location carefully because it is hard to change.
  • Handle errors kindly in the app, such as permission denied, canceled, or network lost.
  • Use lifecycle rules to clean up temporary and old files.
  • Watch your budget with alerts.

Common mistakes

Confusing the two doors

A developer tests with the Admin SDK, where everything works, then finds the app fails for real users because Security Rules block it. Always test with a normal user session.

Trusting the file name

A rule checks the file extension only, and an attacker uploads a harmful file with a fake extension. Check the declared content type and scan content with a function when it matters.

Treating download links as private

A private document is shared through a download link in a chat. Anyone with the link can open it. Use direct SDK reads or expiring signed links for private files.

Storing big files in the database

A team saves photos as text inside the database and the app slows to a crawl. Files belong in Storage, with only their addresses in the database.

Real-world uses

Social and community apps

Profile pictures, post photos, and short videos are uploaded straight from phones. Functions create thumbnails, and rules ensure users edit only their own content.

Messaging apps

Voice notes, images, and documents are sent between users. The message record in the database points to the file in Storage.

Marketplaces and delivery apps

Sellers upload product photos, and drivers upload proof-of-delivery images, each stored in an area owned by that user.

Health, education, and forms

Apps collect scanned documents or homework files. Private rules and expiring links keep each file visible only to the right people. Sensitive data also needs the proper legal and compliance review for your region.

Games

Games download new levels, skins, and updates as files, and players upload screenshots or custom creations.

16Frequently Asked Questions

Q1Is Cloud Storage for Firebase different from Google Cloud Storage?
They share the same storage underneath. Cloud Storage for Firebase adds app-friendly SDKs, Firebase sign-in, and Security Rules on top. Your files sit in a regular Google Cloud Storage bucket that you can also manage from the Google Cloud console.
Q2Do I need my own server to upload files?
No. The app uploads directly to the bucket. You only need server code if you want extra work done, such as scanning or resizing.
Q3Can I use the same bucket for many apps?
Yes, a bucket can serve several apps in one project, and separate rules paths can keep them apart. For stronger separation, use different buckets or projects.
Q4Are my files encrypted?
Yes. Data is encrypted at rest by default, and transfers use secure connections. Customer-managed keys are possible on the Google Cloud side if your rules require them.
Q5What if a download URL is leaked?
You can revoke its token in the console, which makes that link stop working, and then generate a new one. For more control, use direct SDK reads or short-lived signed links.
Q6Can I rename or move a file?
Not in place. Since names are the only identity, a rename means copying the object to a new name and deleting the old one. Server code or the Google Cloud tools can do this.
Q7Why does my upload fail with a permission error?
Usually Security Rules refused it. Check that the user is signed in, that the path matches your rules, and that the file passes your size and type limits. The rules simulator helps find the exact cause.
Q8Can I use it for website images too?
Yes, you can serve public files from a bucket, but for website pages and static assets Firebase Hosting or a content delivery network is often better.
Q9Can I change my bucket’s location later?
Not directly. You would create a new bucket in the right place and move the data. That is why you should choose the location early and carefully.
Q10Is it free?
There is usually some free allowance, but plan requirements and limits have changed over time. Check the current Firebase pricing and your Google Cloud billing settings before you launch, and set budget alerts.

17Summary and Key Takeaways

You began with a phone that needed a safe place to send a photo. You now know that Cloud Storage for Firebase is Google Cloud Storage with a friendly door for apps: simple SDKs, sign-in, rules, and the scale of Google behind it.

Key Takeaways

  • It is Google Cloud Storage made easy for apps. Files go straight from the device to a bucket through the Firebase SDK.
  • Know the vocabulary: buckets hold objects, references are addresses, metadata describes files, and download URLs share them.
  • Security Rules are your front door. Start from deny-all, tie access to the signed-in user, and limit file size and type.
  • Add App Check and budgets to reduce abuse and surprise bills.
  • Remember the two doors: client apps follow Security Rules, while server code and tools follow IAM and can bypass them, so guard admin credentials.
  • Automate with Cloud Functions for thumbnails, scanning, and database updates after each upload.
  • Choose the bucket location and storage class wisely, use lifecycle rules, and always keep the file in Storage and its address in the database.