1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-21 02:33:46 +00:00

downloader for edge and safari

This commit is contained in:
Kyle Spearrin
2018-01-15 10:01:25 -05:00
parent 3cee5970bf
commit b3aaf8063c
7 changed files with 53 additions and 50 deletions

View File

@@ -133,9 +133,8 @@ export class ExportController {
}
private downloadFile(csv: string): void {
const csvBlob = new Blob([csv], { type: 'text/plain' });
const fileName = this.makeFileName();
BrowserApi.downloadFile(this.$window, csvBlob, fileName);
BrowserApi.downloadFile(this.$window, csv, { type: 'text/plain' }, fileName);
}
private makeFileName(): string {

View File

@@ -162,21 +162,7 @@ angular
return cryptoService.decryptFromBytes(req.response, key);
}).then(function (decBuf) {
var blob = new Blob([decBuf]);
if ($window.navigator.msSaveOrOpenBlob) {
// Currently bugged in Edge. See
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8178877/
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8477778/
$window.navigator.msSaveBlob(csvBlob, attachment.fileName);
}
else {
var a = $window.document.createElement('a');
a.href = $window.URL.createObjectURL(blob);
a.download = attachment.fileName;
$window.document.body.appendChild(a);
a.click();
$window.document.body.removeChild(a);
}
BrowserApi.downloadFile($window, decBuf, null, attachment.fileName);
$timeout(function () {
attachment.downloading = false;