Using Firestore wirt ember


#1

Firebase is working very nicely with ember. I would like to use Firestore to store my pictures on the server. Do you thing it’s a good idea? Do you know where I can find a tutorial to upload/download files to firestore and manage this medias in the Firebase.


#2

Firestore isn’t made for storing files. Have you seen https://firebase.google.com/products/storage?

That being said, official support for Firestore via the Emberfire addon is still being worked on: https://github.com/firebase/emberfire/issues/529. You can try out https://github.com/rmmmp/ember-cloud-firestore-adapter instead.

If you’re looking to store pictures, Cloudinary is also a fine alternative that comes with uploader plugins etc.


#3

Thank you for your help. You are right I was confused between Firestore and Firebase storage! I make some test with Cloudinary, it looks very powerful but unfortunately at this time it didn’t success to upload. I am looking to Firebase storage again and I make some progress, this is my controller:

import Controller from ‘@ember/controller’;

import { inject as service } from ‘@ember/service’;

export default Controller.extend({

firebaseApp: service(),

actions: {

	didSelectFiles(files)
			{
            var storage = this.get('firebaseApp').storage;
			console.log("storage : "+ storage);
			var storageRef = storage.ref();
			console.log("storageRef : "+storageRef);
			}
	}

});

I get this answers ;

storage : function () { [native code] }

storageRef: Uncaught TypeError: storage.ref is not a function

what’s wrong in my code?


#4

I get it! I should use firebaseUtil service instead firebaseApp. this.get(‘firebaseUtil’).uploadFile() is working. So easy when you know.


#5

@vincenthure, are you using emberfire-utils? If so, be warned that it’s deprecated. You should just stick to the native Firebase Storage API which was originally what you were using through the firebaseApp service. The problem with your code is that you should’ve executed the storage as a function rather than just a property.

var storage = this.get('firebaseApp').storage();

#6

Thank you, I have changed my code to use “firebaseApp” service and now it work