如何将 zip 文件发送到 api

How to send zip file to api

如何将 zip 文件 (file.zip) 发送到 angular 中的 api。无需解压缩文件然后发送 api 只需将 zip 文件发送到 api

您需要使用FormData接口:

 let file=this.formName.value.imagesfiles[0];      //Store file response into file variable

例如:

let formdata= new FormData();
formdata.append('key_object',file,'filename.zip')  //Appends a new value onto an 
                                                   //existing key inside a FormData object

然后post:

return this.http.post(url,formdata)

Reference.