Firebase Storage lets you upload and share user generated content, such as images and video, which allows you to build rich media content into your apps. Firebase Storage stores this data in a Google Cloud Storage bucket, a petabyte scale object storage solution with high availability and global redundancy. Firebase Storage lets you securely upload these files directly from mobile devices and web browsers, handling spotty networks with ease.
Prerequisites
- Install the Firebase SDK.
- Add your app to your Firebase project in the Firebase console.
Add Firebase Storage to your app
Ensure the following dependency is in your project's Podfile
:
pod 'Firebase/Storage'
Run pod install
and open the created .xcworkspace
file.
Set up Firebase Storage
You must initialize Firebase before any Firebase app reference is created or used. If you have already done this for another Firebase feature, you can skip this step.
- Import the Firebase module:
Objective-C
@import Firebase;
Swift
import Firebase
- Configure a
FIRApp
shared instance, typically in your application'sapplication:didFinishLaunchingWithOptions:
method:Objective-C
// Use Firebase library to configure APIs [FIRApp configure];
Swift
// Use Firebase library to configure APIs FIRApp.configure()
-
Get a reference to the storage service, using the default Firebase App:
Objective-C
FIRStorage *storage = [FIRStorage storage];
Swift
let storage = FIRStorage.storage()
You're ready to start using Firebase Storage! First, let's learn how to create a Firebase Storage reference.