<commit_before># Ember Uploader [![Build Status](https://travis-ci.org/benefitcloud/ember-uploader.png?branch=develop)](https://travis-ci.org/benefitcloud/ember-uploader)

Ember.js file uploader

## Getting Started

Download the [production version][min] or the [development version][max].

[min]: https://raw.github.com/benefitcloud/ember-uploader/master/dist/ember-uploader.min.js
[max]: https://raw.github.com/benefitcloud/ember-uploader/master/dist/ember-uploader.js

or using bower `bower install ember-uploader --save`

#### Basic Setup
Create new component and extend `Ember.FileField` provided by ember-uploader. If you're using `Ember.FileField`, it will automatically give you an input field, and will set `files` property when you choose a file.

```js
App.FileUploadComponent = Ember.FileField.extend({
  url: '',
  filesChange: (function() {
    var uploadUrl = this.get('url');
    var files = this.get('files');

    var uploader = Ember.Uploader.create({
      url: uploadUrl
    });

    if (!Ember.isEmpty(files)) {
      uploader.upload(files[0]);
    }
  }).observes('files')
});
```

Call the component, pass it the url, and thats it!
```hbs
{{file-upload url="/upload"}}
```

#### Ajax request type
By default request will be sent as `POST`. To override that, set `type` when creating the object

```js
var uploader = Ember.Uploader.create({
  url: '/upload',
  type: 'PUT'
});
```

#### JSON Root element (Namespace)

```js
var uploader = Uploader.create({
  paramNamespace: 'post'
});
```

**Output**
```json
{
  "post": {
    "file": { }
  }
}
```

#### Change Parameters
By default parameter will be `file`

```js
var upload = Uploader.create({
  paramName: 'upload'
});
```

**Output**
```json
{
  "upload": {}
}
```

#### Progress

```js
uploader.on('progress', function(e) {
  // Handle progress changes
  // Use `e.percent` to get percentage
});
```

#### Finished Uploading

```js
uploader.on('didUpload', function(e) {
  // Handle finished upload
});
```<commit_msg>DOC: Switch to FormData instead of JSON as output for parameter and namespace<commit_after># Ember Uploader [![Build Status](https://travis-ci.org/benefitcloud/ember-uploader.png?branch=develop)](https://travis-ci.org/benefitcloud/ember-uploader)

Ember.js file uploader

## Getting Started

Download the [production version][min] or the [development version][max].

[min]: https://raw.github.com/benefitcloud/ember-uploader/master/dist/ember-uploader.min.js
[max]: https://raw.github.com/benefitcloud/ember-uploader/master/dist/ember-uploader.js

or using bower `bower install ember-uploader --save`

#### Basic Setup
Create new component and extend `Ember.FileField` provided by ember-uploader. If you're using `Ember.FileField`, it will automatically give you an input field, and will set `files` property when you choose a file.

```js
App.FileUploadComponent = Ember.FileField.extend({
  url: '',
  filesChange: (function() {
    var uploadUrl = this.get('url');
    var files = this.get('files');

    var uploader = Ember.Uploader.create({
      url: uploadUrl
    });

    if (!Ember.isEmpty(files)) {
      uploader.upload(files[0]);
    }
  }).observes('files')
});
```

Call the component, pass it the url, and thats it!
```hbs
{{file-upload url="/upload"}}
```

#### Ajax request type
By default request will be sent as `POST`. To override that, set `type` when creating the object

```js
var uploader = Ember.Uploader.create({
  url: '/upload',
  type: 'PUT'
});
```

#### Change Namespace

```js
var uploader = Uploader.create({
  paramNamespace: 'post'
});

// will be sent as -> post[file]=...
```

#### Change Parameters
By default parameter will be `file`

```js
var upload = Uploader.create({
  paramName: 'upload'
});

// will be sent as -> upload=...
```

#### Progress

```js
uploader.on('progress', function(e) {
  // Handle progress changes
  // Use `e.percent` to get percentage
});
```

#### Finished Uploading

```js
uploader.on('didUpload', function(e) {
  // Handle finished upload
});
```
{'fraction_non_alphanumeric': 0.1698207171314741, 'fraction_numerical': 0.00049800796812749, 'mean_word_length': 4.130268199233717, 'pattern_counts': {'":': 3, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7497413', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1295, 'n_words': 363}