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

use downloader page to dl files on safari

This commit is contained in:
Kyle Spearrin
2018-01-13 23:57:58 -05:00
parent 00b2c47aae
commit 5d551c5d70
4 changed files with 62 additions and 16 deletions

View File

@@ -2,6 +2,8 @@ import * as angular from 'angular';
import * as papa from 'papaparse';
import * as template from './export.component.html';
import { BrowserApi } from '../../../browser/browserApi';
import { CipherType } from 'jslib/enums/cipherType';
import { CipherService } from 'jslib/abstractions/cipher.service';
@@ -133,20 +135,7 @@ export class ExportController {
private downloadFile(csv: string): void {
const csvBlob = new Blob([csv], { type: 'text/plain' });
const fileName = this.makeFileName();
if (this.$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/
this.$window.navigator.msSaveBlob(csvBlob, fileName);
} else {
const a = this.$window.document.createElement('a');
a.href = this.$window.URL.createObjectURL(csvBlob);
a.download = fileName;
this.$window.document.body.appendChild(a);
a.click();
this.$window.document.body.removeChild(a);
}
BrowserApi.downloadFile(this.$window, csvBlob, fileName);
}
private makeFileName(): string {