Click here to Skip to main content
15,867,141 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
zip files not downloaded on angular 13 although zip files created and api not give error ?

I work on application asp.net web api core 2.2 and angular 13 .

I make web api compress files and create it first as zip files .

then downloaded on my pc

compress file as zip extension correctly created .

issue done when download file on my pc

data response after finish

ERROR HttpErrorResponse {headers: HttpHeaders, status: 500, statusText: 'Internal Server Error', url: 'http://localhost:61265/api/Z2Delivery/ExportNormalizedRelation/', ok: false, …}

for more details see link below
File sharing and storage made simple[^]

What I have tried:

what i try
on web api 
 [HttpPost, DisableRequestSizeLimit]
        [Route("ExportNormalizedRelation")]
        public IActionResult ExportNormalizedRelation()
        {
           return File(zipPath, "text/plain", Path.GetFileName(zipPath));

        }
service angular

PostUploadzip(selectedoptionsId:Number, file:any):Observable<any>
{
  const formData: FormData = new FormData();
  formData.append('file', file,file.name);
  formData.append('selectedoptions',selectedoptionsId.toString());
  return this.http.post('http://localhost:61265/api/Z2Delivery/ExportNormalizedRelation/', formData,{responseType: 'blob'});
}
ts angular
 public uploadFile = (selectedoptions:number) => {
   
  this.selectedoptions= selectedoptions;
  this.fileToUpload = this.selectedFiles.item(0);
      this._dataService.PostUploadzip(this.selectedoptions,this.fileToUpload)
      
       .subscribe((response: Blob) => saveAs(response, this.fileToUpload?.name + '.zip'));
       
}
html angular
<div class="row">
    <div><button (click)="uploadFile(2)">Export Normalized Relation</button></div>
  </div>
Posted
Comments
Richard Deeming 31-Mar-22 10:39am    
A 500 response means there was an error in your server code. You need to see the details of that error to work out what the problem is.

Examine the network request response in your browser's developer tools to see whether the exception details are included. If not, you'll need to debug your code.
ahmed_sa 31-Mar-22 10:50am    
thank you for reply can you help me please
when i debug my api it not give me exception
so how it server error

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900