0
0
Firebasecloud~5 mins

Deleting files in Firebase - Commands & Configuration

Choose your learning style9 modes available
Introduction
Sometimes you need to remove files from your Firebase Storage to free up space or remove outdated content. Deleting files helps keep your storage clean and organized.
When you want to remove old images that are no longer used in your app.
When you need to delete user-uploaded files after account deletion.
When cleaning up temporary files created during processing.
When replacing files with updated versions and removing the old ones.
When managing storage costs by deleting unnecessary files.
Commands
This command deletes the file named 'photo1.jpg' inside the 'images' folder in Firebase Storage. Use it to remove a specific file you no longer need.
Terminal
firebase storage:delete images/photo1.jpg
Expected OutputExpected
✔ Deleted images/photo1.jpg
--force - Deletes the file without asking for confirmation.
This command lists all files inside the 'images' folder so you can see what files exist before deleting.
Terminal
firebase storage:list images
Expected OutputExpected
images/photo1.jpg images/photo2.jpg images/photo3.jpg
Deletes 'photo2.jpg' without asking for confirmation, useful for scripts or batch deletions.
Terminal
firebase storage:delete images/photo2.jpg --force
Expected OutputExpected
✔ Deleted images/photo2.jpg
--force - Skips confirmation prompt.
Key Concept

If you remember nothing else, remember: use the 'firebase storage:delete' command with the exact file path to remove files from Firebase Storage.

Common Mistakes
Trying to delete a file without specifying the full path.
Firebase Storage requires the exact path to the file; otherwise, it cannot find the file to delete.
Always include the full path relative to the storage root, like 'folder/filename.ext'.
Not using the --force flag and expecting no confirmation prompt.
Without --force, the command asks for confirmation, which can pause scripts or automation.
Add --force to delete files non-interactively.
Summary
Use 'firebase storage:list' to see files before deleting.
Delete files with 'firebase storage:delete' followed by the file path.
Use '--force' to skip confirmation prompts during deletion.