bitwarden-estensione-browser/apps/desktop/src/app/services/desktop-file-download.servi...

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
820 B
TypeScript
Raw Normal View History

import { Injectable } from "@angular/core";
import { FileDownloadBuilder } from "@bitwarden/common/platform/abstractions/file-download/file-download.builder";
import { FileDownloadRequest } from "@bitwarden/common/platform/abstractions/file-download/file-download.request";
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
@Injectable()
export class DesktopFileDownloadService implements FileDownloadService {
download(request: FileDownloadRequest): void {
const a = window.document.createElement("a");
a.href = URL.createObjectURL(new FileDownloadBuilder(request).blob);
a.download = request.fileName;
a.style.position = "fixed";
window.document.body.appendChild(a);
a.click();
window.document.body.removeChild(a);
}
}