From b34e511ddc366ad617753a13e9eaa70ea1b57046 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 8 Jun 2018 12:23:46 -0400 Subject: [PATCH] savefile imeplementation --- src/services/webPlatformUtils.service.ts | 13 ++++++++++++- src/services/webStorage.service.ts | 1 - 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/services/webPlatformUtils.service.ts b/src/services/webPlatformUtils.service.ts index b2c65b8931..0f52f74280 100644 --- a/src/services/webPlatformUtils.service.ts +++ b/src/services/webPlatformUtils.service.ts @@ -74,7 +74,18 @@ export class WebPlatformUtilsService implements PlatformUtilsService { } saveFile(win: Window, blobData: any, blobOptions: any, fileName: string): void { - // + const blob = new Blob([blobData], blobOptions); + if (navigator.msSaveOrOpenBlob) { + navigator.msSaveBlob(blob, fileName); + } else { + const a = win.document.createElement('a'); + a.href = win.URL.createObjectURL(blob); + a.download = fileName; + a.style.position = 'fixed'; + win.document.body.appendChild(a); + a.click(); + win.document.body.removeChild(a); + } } getApplicationVersion(): string { diff --git a/src/services/webStorage.service.ts b/src/services/webStorage.service.ts index f8f49108c7..271f2ff926 100644 --- a/src/services/webStorage.service.ts +++ b/src/services/webStorage.service.ts @@ -24,5 +24,4 @@ export class WebStorageService implements StorageService { window.sessionStorage.removeItem(key); return Promise.resolve(); } - }