11# Ember-cli-filepicker
22
33[ ![ npm version] ( https://badge.fury.io/js/ember-cli-filepicker.svg )] ( http://badge.fury.io/js/ember-cli-filepicker )
4- [ ![ Build Status] ( https://travis-ci.org/DudaDev/ember-cli-filepicker.svg )] ( https://travis-ci.org/DudaDev/ember-cli-filepicker )
4+ [ ![ Build Status] ( https://travis-ci.org/DudaDev/ember-cli-filepicker.svg )] ( https://travis-ci.org/DudaDev/ember-cli-filepicker )
55
66## Installation
77
1111* Create your filepicker.io key using the following URL: https://www.filepicker.io/ .
1212* Add your filepicker.io key in your config/environment.js
1313```
14- //config/environment.js
14+ //config/environment.js
1515module.exports = function(environment) {
1616 var ENV = {
1717 //...
@@ -22,46 +22,42 @@ module.exports = function(environment) {
2222* Use the filepicker.io documentation for options like extensions and services.
2323* In your template:
2424```
25- {{ember-filepicker pickerOptions=pickerOptions onSelection='fileSelected' onClose='onClose' onError='onError'}}
26- ```
27- * The above will use the pick method.
28- * You should pass pickerOptions with the pick options (mimetype, services, etc).
29-
30- * If you want to use pickAndStore, also pass storeOptions (location, etc):
31- ```
32- {{ember-filepicker pickerOptions=pickerOptions storeOptions=storeOptions onSelection='fileSelected' onClose='onClose' onError='onError'}}
25+ {{ember-filepicker options=options onSelection='fileSelected' onClose='onClose' onError='onError'}}
3326```
27+ * The default usage of the above is the pick method.
28+ * You should pass options.picker with the pick options (mimetype, services, etc).
29+ * If you want to use pickAndStore, add an options.useStore flag and options.store (location, etc).
3430
3531
3632## Notes
3733In order to have access to the ` filepicker ` instance you can:
3834* If ` Ember.inject.service ` is supported then in your object you can use:
3935```
4036export default Ember.Component.extend({
41- //injecting the filepicker object
42- filepicker: Ember.inject.service(),
43-
44- someFunction: function(){
45- //Use the promise in case you are not sure that your component will be surly initialized after filepicker has been loaded
46- this.get('filepicker.promise').then(function(filepicker){
47- //do something with filepicker
48- });
49-
50- //OR if you are sure filepicker has already been loaded use:
51- this.get('filepicker.instance')
52- }
37+ //injecting the filepicker object
38+ filepicker: Ember.inject.service(),
39+
40+ someFunction: function(){
41+ //Use the promise in case you are not sure that your component will be surly initialized after filepicker has been loaded
42+ this.get('filepicker.promise').then(function(filepicker){
43+ //do something with filepicker
44+ });
45+
46+ //OR if you are sure filepicker has already been loaded use:
47+ this.get('filepicker.instance')
48+ }
5349});
5450```
5551* Otherwise, you can use the lookup method:
5652```
5753export default Ember.Component.extend({
58- //injecting the filepicker object
59- filepicker: Ember.inject.service(),
54+ //injecting the filepicker object
55+ filepicker: Ember.inject.service(),
6056
61- someFunction: function(){
62- var filepicker = this.container.lookup('service:filepicker');
63- //do something with the filepicker.instance or filepicker.promise
64- }
57+ someFunction: function(){
58+ var filepicker = this.container.lookup('service:filepicker');
59+ //do something with the filepicker.instance or filepicker.promise
60+ }
6561});
6662```
6763
0 commit comments