-
-
Notifications
You must be signed in to change notification settings - Fork 5
Storage Use File Metadata
The contents of this page are based on the original Firebase Documentation
After uploading a file to Cloud Storage reference, you can also get and update the file metadata, for example to update the content type. Files can also store custom key/value pairs with additional file metadata.
Note: By default, Cloud Storage buckets require Firebase Authentication to upload files. You can change your Firebase Security Rules for Cloud Storage to allow unauthenticated access. Since the default Google App Engine app and Firebase share this bucket, configuring public access may make newly uploaded App Engine files publicly accessible as well. Be sure to restrict access to your Storage bucket again when you set up authentication.
File metadata contains common properties such as name, size, and contentType (often referred to as MIME type) in addition to some less common ones like contentDisposition and timeCreated. This metadata can be retrieved from a Cloud Storage reference using the getMetadata method.
// Create reference to the file whose metadata we want to retrieve
var forestRef:StorageReference = storageRef.child("images/forest.jpg");
// Get metadata properties
forestRef.getMetadata(function (metadata:StorageMetadata, error:StorageError):void {
});You can update file metadata at any time after the file upload completes by using the updateMetadata method. Refer to the full list for more information on what properties can be updated. Only the properties specified in the metadata are updated, all others are left unmodified.
// Create file metadata to update
var newMetadata:StorageMetadata = new StorageMetadata();
newMetadata.cacheControl = "public,max-age=300";
newMetadata.contentType = "image/jpeg";
storageRef.updateMetadata(newMetadata, function (error:StorageError):void {
});You can delete writable metadata properties by passing the empty string:
var newMetadata:StorageMetadata = new StorageMetadata();
newMetadata.contentType = "";
storageRef.updateMetadata(newMetadata, function (error:StorageError):void {
});You can specify custom metadata as an Object containing String properties.
newMetadata.customMetadata = {
"location": "Yosemite, CA, USA",
"activity": "Hiking"
};Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.
Project setup
Analytics
Authentication
Dynamic Links
Google Sign In
Firestore
- Configuring the ANE
- Get Started
- Add and Manage Data
- Query Data
- Get Data
- Get Realtime Updates
- Perform Simple and Compound Queries
- Order and Limit Data
- Paginate Data
Messaging
One Signal
Performance
Remote Config
Storage
- Configuring the ANE
- Get Started
- Create a Reference
- Upload Files
- Download Files
- Use File Metadata
- Delete Files
Crashlytics
Vision
- Detect faces
- Scan barcodes
- Label images
- Recognize landmarks
- Natural Language
- Custom Models
External Links