Created
October 13, 2014 13:39
-
-
Save abuiles/5878f905c51714775b36 to your computer and use it in GitHub Desktop.
This file contains 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'; | |
import { request } from 'ic-ajax'; | |
export default Ember.Component.extend({ | |
actions: { | |
upload: function() { | |
var _this = this; | |
var formData = new FormData(); | |
formData.append("file", this.$('input')[0].files[0]); | |
var url = this.get('url'); | |
request('/your-api-end-point-which-accepts-csv', { | |
type: 'POST', | |
data: formData, | |
dataType: 'json', | |
processData: false, | |
contentType: false, | |
xhr: function() { | |
var xhr; | |
xhr = Ember.$.ajaxSettings.xhr(); | |
xhr.upload.onprogress = function(evt) { | |
return _this.set('uploadProgress', evt.loaded / evt.total * 100); | |
}; | |
return xhr; | |
} | |
}).then(function() { | |
console.log('manage success here'); | |
}, function() { | |
console.log('manage failure'); | |
}); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment