ahmed elbarbary

ahmed elbarbary

  • NA
  • 1.6k
  • 275.4k

File created with name [object formdata] but it must be name delivery.

Dec 7 2020 7:55 PM
I work on asp.net core 2.2 Project with angular 7 . I face issue when download file
It created with Name [object FormData].xlsx but Name must be DeliveryGeneration_Output.xlsx .
on Angular 7
  1. public uploadFile = (files) => {  
  2. const formData = new FormData();  
  3. formData.append('file'this.fileToUpload,this.fileToUpload.name);  
  4. this.http.post('https://localhost:44396/api/ApprovalQuality/', formData,{ responseType: 'blob' })  
  5. .subscribe((response: Blob) => saveAs(response, formData + '.xlsx'));  
  6. }  
on Web API .Net Core 2.2
  1. var memory2 = new MemoryStream();  
  2. using (var stream = new FileStream(exportPath, FileMode.Open))  
  3. {  
  4. stream.CopyTo(memory2);  
  5. }  
  6. memory2.Position = 0;  
  7. return File(memory2, "text/plain", Path.GetFileName(exportPath));  
Path returned and Created
\\192.168.2.7\\ImportExport\\2\\Export\DeliveryGeneration_Output.xlsx
 
so why file name created with [object FormData].xlsx and not created with DeliveryGeneration_Output.xlsx
and How to solve this Issue ?

Answers (1)