-
Notifications
You must be signed in to change notification settings - Fork 16
E.2 Init Storage
You can initialize the Storage by calling Storage.init();
As soon as you initialized the firebaseStorage.ane in your project, you will be ready to create references to different locations of your storage.
Your files are stored in a Firebase Storage bucket. The files in this bucket are presented in a hierarchical structure, just like the file system on your local hard disk, or the data in the Firebase Realtime Database. By creating a reference to a file, your app gains access to it. These references can then be used to upload or download data, get or update metadata or delete the file. A reference can either point to a specific file or to a higher level in the hierarchy.
If you've used the Firebase Realtime Database, these paths should seem very familiar to you. However, your file data is stored in Google Cloud Storage, not in the Realtime Database.
NOTE: Make sure you have already initialized the Firebase core before trying any other Firebase child ANEs.
Create a reference to upload, download, or delete a file, or to get or update its metadata. A reference can be thought of as a pointer to a file in the cloud. References are lightweight, so you can create as many as you need. They are also reusable for multiple operations.
References are created from the Storage class on your Firebase app by calling the getReference method. The getReference
method accepts different forms of inputs which you can use to create references to the root or a child location in the storage.
// create a storage reference from URL
var storageRef:StorageReference = Storage.getReference(null, "gs://your-storage.appspot.com");
// create a storage reference to the root like above
var storageRef:StorageReference = Storage.getReference();
You can create a reference to a location lower in the tree, say 'images/space.jpg', by using the child method on an existing reference.
// Create a child reference. spaceRef now points to "space.jpg"
var spaceRef:StorageReference = storageRef.child("images/space.jpg");
// References can be chained together multiple times. earthRef points to "images/earth.jpg"
var earthRef:StorageReference = spaceRef.parent.child("earth.jpg");
// nilRef is null, since the parent of root is null
var nilRef:StorageReference = spaceRef.root.parent;
You can inspect references to better understand the files they point to using the path, name, and bucket properties. These properties get the file's full path, name, and bucket.
trace(spaceRef.path); // "images/space.jpg"
trace(spaceRef.name); // "space.jpg"
trace(spaceRef.bucket); // name of the storage bucket that the files are stored in
Reference paths and names can contain any sequence of valid Unicode characters, but certain restrictions are imposed including:
- Total length of reference.fullPath must be between 1 and 1024 bytes when UTF-8 encoded.
- No Carriage Return or Line Feed characters.
- Avoid using
#
,[
,]
,*
, or?
, as these do not work well with other tools such as the Firebase Realtime Database or gsutil.
Enjoy building Air apps – With ♥ from MyFlashLabs Team
Introduction to Firebase ANEs collection for Adobe Air apps
Get Started with Firebase Core in AIR
- Prerequisites
- Add Firebase to your app
- Add the Firebase SDK
- Init Firebase Core
- Available ANEs
- Managing Firebase iid
Get Started with Authentication
- Add Authentication
- Init Authentication
- Manage Users
- Phone Number
- Custom Auth
- Anonymous Auth
- State in Email Actions
- Email Link Authentication
Get Started with FCM + OneSignal
- Add FCM ANE
- Init FCM ANE
- Send Your 1st Message
- Send Msg to Topics
- Understanding FCM Messages
- init OneSignal
- Add Firestore
- Init Firestore
- Add Data
- Transactions & Batches
- Delete Data
- Manage the Console
- Get Data
- Get Realtime Updates
- Simple and Compound
- Order and Limit Data
- Paginate Data
- Manage Indexes
- Secure Data
- Offline Data
- Where to Go From Here
Get Started with Realtime Database
- Add Realtime Database
- Init Realtime Database
- Structure Your Database
- Save Data
- Retrieve Data
- Enable Offline Capabilities
Get Started with Remote Config
- Add Storage ANE
- Init Storage ANE
- Upload Files to Storage
- Download Files to Air
- Use File Metadata
- Delete Files