emberUploader upload multiple files problem

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 ?

Hi @aragoubi, what happens if you put some logpoints or breakpoints in and inspect some of the state? Like args when it is assigned at let args = this.get('files');?

Unfortunately this looks like very old Ember code (Ember.K, for example, has been deprecated for a long time) and there’s not a lot of context here (is EmberUploader an addon or is it a custom component? what does the template invocation for this component look like?) so I’m not sure how helpful we’ll be able to be…

Thank you for your answer, Acutally I resolved the problem, the problem was my backend code, I should put file[ ] at the requestParam.

Awesome! Glad you got it working.