Last active
June 6, 2016 16:19
-
-
Save grapho/b93ff79371d49865aff19db757a8c93f to your computer and use it in GitHub Desktop.
Upload Queue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| const { | |
| RSVP, | |
| $: { ajax } | |
| } = Ember; | |
| export default Ember.Controller.extend({ | |
| appName: 'Uploading Hell', | |
| formData: Ember.computed(function() { | |
| return new FormData(); | |
| }), | |
| queuedFiles: Ember.computed(function() { | |
| return this.get('formData').getAll('file[]'); | |
| }), | |
| sendFileAttachments(id) { | |
| console.log('sendFileAttachments'); | |
| let url = `api/rest/account/document?account_id=${id}`; | |
| let files = this.get('queuedFiles'); | |
| let formData = this.get('formData'); | |
| console.log(formData.getAll('file[]')); | |
| return ajax({ | |
| url: url, | |
| cache: false, | |
| method: 'POST', | |
| data: formData, | |
| processData: false, | |
| contentType: false, | |
| headers: { | |
| 'Accept': 'application/json; version=1.0.0', | |
| } | |
| }); | |
| }, | |
| actions: { | |
| addFileToQueue(FileList) { | |
| console.log('FileList'); | |
| console.log(FileList); | |
| let formData = this.get('formData'); | |
| for (let i = 0; i < FileList.length; i++) { | |
| formData.append(`file[]`, FileList[i], FileList[i].name); | |
| } | |
| this.notifyPropertyChange('queuedFiles'); | |
| }, | |
| upload() { | |
| this.sendFileAttachments(1); | |
| } | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "version": "0.8.1", | |
| "EmberENV": { | |
| "FEATURES": {} | |
| }, | |
| "options": { | |
| "use_pods": false, | |
| "enable-testing": false | |
| }, | |
| "dependencies": { | |
| "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
| "ember": "2.5.1", | |
| "ember-data": "2.5.3", | |
| "ember-template-compiler": "2.5.1" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment