Spring boot backend receiving empty Files array from EmberJs component EmberUploader When upload multiple files

邮差的信 提交于 2021-02-05 11:48:37

问题


I have an ember component responsible of uploading multiple File, 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);
    var j = Array.from(this.get('_files'));
    this.get('files').pushObject(j);
  }
  
    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('files')).then(data => {
        this.$().val('');
        this.get('success')(data);
      }, error => {
        this.$().val('');
        this.get('failure')(error);
      });
    }
  })
});

This is my spring boot controller :

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 putting this.get('files')[0] withing args.

Why this is not working for multiple files?

来源:https://stackoverflow.com/questions/63414184/spring-boot-backend-receiving-empty-files-array-from-emberjs-component-emberuplo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!