Provides file picking, storing, and converting funtionality from Filestack using v3+ of their API.
This addon borrows from and builds heavily on Ember-cli-filepicker
ember install ember-filestack
- Create your filestack.com key here: https://www.filestack.com/.
- Add your filestack.com key in your config/environment.js
//config/environment.js
module.exports = function(environment) {
var ENV = {
//...
filestackKey: '<your-filestack-key>'
};
//...
}
- Use the filestack.com documentation for options like extensions and services.
- In your template:
- You then pass the options and actions to determine the picker's behaviour.
export default Ember.Component.extend({
options: {
accept: ['image/*'],
maxSize: 10485760
},
actions: {
fileSelected(result) {
// the `filesUploaded` is an array of files you've just uploaded
console.log(result.filesUploaded);
},
onClose() {
// ...
},
onError(file, error) {
// ...
}
}
});
- Complete documentation of all the available options and response data can be found here.
In order to have access to the filestack
instance you can:
- If
Ember.inject.service
is supported then in your object you can use:
export default Ember.Component.extend({
//injecting the filestack object
filestack: Ember.inject.service(),
someFunction: function(){
// Use the promise in case you are not sure that your component will be initialized after filestack has been loaded
this.get('filestack.promise').then(function(filestack){
// do something with filestack
});
// OR if you are sure filestack has already been loaded use:
this.get('filestack.instance')
}
});
ember serve
- Visit your app at http://localhost:4200.
npm test
(Runsember try:each
to test your addon against multiple Ember versions)ember test
ember test --server
ember build
For more information on using ember-cli, visit https://ember-cli.com/.