eligrey / eligrey/FileSaver.js

saveAs doesn't work on microsoft Edge

Open
#584 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
22k
Forks
4.3k
PR merge metrics
No merged PRs in 30d

Description

Hi, I am utilizing FileSaver to save files to a clients machine.
The file to be downloaded is an excell file which is being sent as a blob via a HttpResponse
However when using edge the browser downloads a .txt file with the name of (x).txt

Other browsers Chrome, Firefox, IE work fine and download the excel file with naming as expected
Something i'm missing for edge to work?

The code:
```js
public getRequestsExport(filter: RequestFilterDto): Observable {
const url = environment.BACKEND_BASE_PATH + '/home/requests/requests-export';
return this.http
.post(url, filter, {
responseType: 'blob',
})
.pipe(
log('download requests export'),
tap((response: HttpResponse) => {
const today = new Date();
const date = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();
const time = today.getHours() + ':' + today.getMinutes() + ':' + today.getSeconds();
const dateTime = date + ' ' + time;
let fileName = '';
this.translateService
.get('ExportRequests_FileName')
.pipe(
take(1),
tap(fn => {
fileName = fn;
})
)
.subscribe();

FileSaver.saveAs(response, fileName + dateTime + klifeConstants.EXCEL_EXTENSION);
})
);
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.