- Serverless Web Applications with React and Firebase
- Harmeet Singh Mayur Tanna
- 217字
- 2021-08-27 19:11:12
Cloud Storage
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.
推薦閱讀
- 新一代通用視頻編碼H.266/VVC:原理、標準與實現
- Cocos2d-x游戲開發:手把手教你Lua語言的編程方法
- Data Analysis with Stata
- Python高效開發實戰:Django、Tornado、Flask、Twisted(第3版)
- 深度強化學習算法與實踐:基于PyTorch的實現
- C語言程序設計案例精粹
- Python時間序列預測
- Visual C++開發入行真功夫
- Learning Apache Karaf
- Python3.5從零開始學
- NGUI for Unity
- Akka入門與實踐
- Python Social Media Analytics
- 計算機組裝與維護(第二版)
- 深入大型數據集:并行與分布化Python代碼