File Upload with Angular2 to REST API

后端 未结 9 1088
萌比男神i
萌比男神i 2020-11-27 10:14

Actually, I\'m working on a Spring REST API with an interface coded in Angular 2.

My problem is I can\'t upload a file with Angular 2.

My Webresources in jav

9条回答
  •  佛祖请我去吃肉
    2020-11-27 10:52

    I was just removed content-type from the header. for example this is our header:

     let headers = new Headers({
            'Authorization': 'Bearer ' + this.token,
            'Content-Type': 'multipart/form-data'
    });
    

    What you have to do is to just remove Content-Type from this. Like:

     let headers = new Headers({
            'Authorization': 'Bearer ' + this.token,
        });
    

提交回复
热议问题