You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Nicolas Garnier dc2519ea4a Updating version of the firebase-functions module in package.json files to launch version 8 years ago
..
functions Updating version of the firebase-functions module in package.json files to launch version 8 years ago
public Updating "Firebase" Functions and Storage naming following the rebranding to "Cloud". 8 years ago
README.md update exif-images README 8 years ago
database.rules.json Add the exif-image sample. 8 years ago
firebase.json Add the exif-image sample. 8 years ago

README.md

Automatically Extract Images Metadata

This sample demonstrates how to automatically extract images metadata that are uploaded to Firebase Storage ImageMagick.

Functions Code

See file functions/index.js for the code.

The image metadata is provided using ImagMagick identify tool which is installed by default on all Cloud Functions instances. This is a CLI for which we use a NodeJS wrapper. The image is first downloaded locally from the Firebase Storage bucket to the tmp folder using the google-cloud SDK.

The dependencies are listed in functions/package.json.

Trigger rules

The function triggers on upload of any file to your Firebase project default Cloud Storage bucket.

Storage and Database Structure

Users upload an image to Firebase Storage to the path /<timestamp>/<filename> and in return the Function will write to the /<timestamp>/<filename> path in the database. The filename typically contains illegal characters for a Firebase Realtime Database keys (such as .) so we're replacing all these by the * character.

For example the metadata for the file at path /1477402116302/mypic.jpg will be written to the corresponding Database path /1477402116302/mypic*jpg

Setting up the sample

This sample comes with a Function and web-based UI for testing the function. To configure it:

  • Create a Firebase project on the Firebase Console
  • Enable Anonymous sign in the Auth section
  • Import and configure Firebase in the index.html where the TODO is located

Deploy and test

To test the sample:

  • Deploy your project using firebase deploy
  • Open the Deploy Web UI using firebase open, typically at the URL https://<projectID>.firebaseapp.com
  • Upload an image using the Web UI.
  • You should see the metadata displayed below after a bit.