8000 GitHub - nolman/ember-filestack: Support for Filestack service within EmberJS
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

nolman/ember-filestack

 
 

Repository files navigation

Ember-filestack

npm version Build Status Ember Observer Score

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

Installation

  • ember install ember-filestack

Usage

//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:
{{ember-filestack-picker options=options onSelection=(action 'fileSelected') onClose=(action 'onClose') onError=(action 'onError')}}
  • 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.

Notes

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')
  }
});

Running

Running Tests

  • npm test (Runs ember try:each to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit https://ember-cli.com/.

About

Support for Filestack service within EmberJS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 86.2%
  • HTML 13.8%
0