mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 17:53:39 +00:00
[fix] Force send attachment to always download and never open (#2908)
* [refactor] Introduce a file download service * [refactor] Point platformUtilsService.saveFile() callers to fileDownloadService.download() instead * [refactor] Remove platformUtilsService.saveFile() * [fix] Force send attachments to always download and never open * [fix] Remove the window property from FileDownloadRequest * [fix] Move FileDownloadRequest to /abstractions/fileDownload * [fix] Simplify FileDownloadRequest to a type * [fix] Move BrowserApi.saveFile logic into BrowserFileDownloadService * [fix] Use proper blob types for file downloads * [fix] forceDownload -> downloadMethod on FileDownloadRequest * [fix] Remove fileType from FileDownloadRequest * [fix] Make fileType private
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Directive } from "@angular/core";
|
||||
|
||||
import { ExportService } from "@bitwarden/common/abstractions/export.service";
|
||||
import { FileDownloadService } from "@bitwarden/common/abstractions/fileDownload/fileDownload.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
@@ -30,7 +31,8 @@ export abstract class BaseEventsComponent {
|
||||
protected i18nService: I18nService,
|
||||
protected exportService: ExportService,
|
||||
protected platformUtilsService: PlatformUtilsService,
|
||||
protected logService: LogService
|
||||
protected logService: LogService,
|
||||
protected fileDownloadService: FileDownloadService
|
||||
) {
|
||||
const defaultDates = this.eventService.getDefaultDateFilters();
|
||||
this.start = defaultDates[0];
|
||||
@@ -173,6 +175,10 @@ export abstract class BaseEventsComponent {
|
||||
|
||||
const data = await this.exportService.getEventExport(events);
|
||||
const fileName = this.exportService.getFileName(this.exportFileName, "csv");
|
||||
this.platformUtilsService.saveFile(window, data, { type: "text/plain" }, fileName);
|
||||
this.fileDownloadService.download({
|
||||
fileName,
|
||||
blobData: data,
|
||||
blobOptions: { type: "text/plain" },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user