Any mobile or web app will need a storage space that stores user-generated content such as documents, photos, or videos in a secure manner and scales well. Cloud Storage is designed with the same requirement in mind and helps you easily store and serve user-generated content. It provides a robust streaming mechanism for a best end-user experience.
Here's how we can configure Firebase Cloud Storage:
// Configuration for your app
// TODO: Replace with your project's config object
var config = {
apiKey: '<your-api-key>',
authDomain: '<your-auth-domain>',
databaseURL: '<your-database-url>',
storageBucket: '<your-storage-bucket>'
};
firebase.initializeApp(config);
// Get a reference to the storage service
var storage = firebase.storage();
// Points to the root reference
var storageRef = storage.ref();
// Points to 'images'
var imagesRef = storageRef.child('images');
// Points to 'images/sprite.jpg'
// Note that you can use variables to create child values
var fileName = 'sprite.jpg';
var spaceRef = imagesRef.child(fileName);
// File path is 'images/sprite.jpg'
var path = spaceRef.fullPath
// File name is 'sprite.jpg'
var name = spaceRef.name
// Points to 'images'
var imagesRef = spaceRef.parent;
The total length of reference.fullPath must be between 1 and 1,024 bytes, with no Carriage Return or Line Feed characters.
Avoid using #, [, ], *, or ?, as these do not work well with other tools such as Firebase Realtime Database.
Avoid using #, [, ], *, or ?, as these do not work well with other tools such as Firebase Realtime Database.