Skip to content

Commit

Permalink
add send-file-name option
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-evans committed Nov 28, 2016
1 parent 6581fb6 commit 08be589
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ The `{{pl-uploader}}` component exposes a variety of parameters for configuring
| `multiple` | whether multiple files can be selected
| `unique-names` | when set to `true`, this will rename files sent to the server and send the original name as a parameter named `name`
| `send-browser-cookies` | when set to `true`, this option will be added to the `required_features` of plupload (and enable `withCredentials`)
| `send-file-name` | whether to send the file name with the upload. This defaults to the plupload default.
| `runtimes` | a space-separated list of runtimes for plupload to attempt to use (in order of importance)

This configuration is for the uploader instance as a whole. Most of the configuration deals directly with the feel of the uploader. When the queued event is triggered, you will be given a file object that allows you to configure where the file is being uploaded:
Expand Down
5 changes: 5 additions & 0 deletions addon/components/pl-uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export default Ember.Component.extend({
multiple: true,
'unique-names': false,
'send-browser-cookies': false,
'send-file-name': null,

dropzone: computed('for-dropzone', {
get() {
Expand Down Expand Up @@ -107,6 +108,10 @@ export default Ember.Component.extend({
config.required_features.send_browser_cookies = true;
}

if (get(this, 'send-file-name') != null) {
config.send_file_name = get(this, 'send-file-name');
}

var filters = get(this, 'fileFilters') || {};
keys(filters).forEach((filter) => {
if (get(this, filter)) {
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/components/pl-uploader-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ test('it configures the plupload Uploader correctly', function (assert) {
extensions: 'JPG PNG GIF',
'max-file-size': 256,
'no-duplicates': true,
'send-file-name': true,
uploader: Uploader.create()
});

Expand All @@ -48,6 +49,7 @@ test('it configures the plupload Uploader correctly', function (assert) {
unique_names: false,
multi_selection: true,
required_features: {},
send_file_name: true,
filters: {
mime_types: [{
extensions: 'jpg,png,gif'
Expand All @@ -71,6 +73,7 @@ test('when html5 is not a runtime, drop_element is not included', function (asse
extensions: 'JPG PNG GIF',
'max-file-size': 256,
'no-duplicates': true,
'send-file-name': false,
uploader: Uploader.create(),
runtimes: 'html4 flash'
});
Expand All @@ -91,6 +94,7 @@ test('when html5 is not a runtime, drop_element is not included', function (asse
unique_names: false,
multi_selection: true,
required_features: {},
send_file_name: false,
filters: {
mime_types: [{
extensions: 'jpg,png,gif'
Expand Down

0 comments on commit 08be589

Please sign in to comment.