I have an ember component uploading files, this works only with one file, but if I want to upload multiple files, it doesn’t work, and I am getting an empty array at my backend. This is my component:
export default EmberUploader.FileField.extend({
multiple: true,
method: 'POST',
success: Ember.K,
failure: Ember.K,
updateLabel: Ember.K,
start: false,
change(event) {
this.set('_files',event.target.files);
}
startUpload: Ember.observer('_files.[]', 'start', function() {
if (!Ember.isEmpty(this.get('_files')) && this.get('start')) {
const uploader = EmberUploader.Uploader.create({
url: this.get('url'),
method: this.get('method')
});
let args = this.get('files');
let data = this.get('data');
if (data) {
args.push({data: data});
}
uploader.upload(this.get('args')).then(data => {
this.$().val('');
this.get('success')(data);
}, error => {
this.$().val('');
this.get('failure')(error);
});
}
})
});
this is my backend endpoint:
public List<FileData> upload(@RequestPart("data") MemberData memberData, @RequestParam("files") MultipartFile[] uploadedFiles) throws SizeLimitExceededException { ... }
My problem is that I am getting an empty array of uploadedFiles. This works fine with on file, when using MultipartFile instead of MultipartFile[ ] and assigning this.get(‘files’)[0] to the variable args.
Why this is not working for multiple files? Could someone help with this ?