Browse Source

Merge pull request #5350 from abpframework/feat/5348

feat: add downloadBlob with file-utils
pull/5368/head
Bunyamin Coskuner 6 years ago
committed by GitHub
parent
commit
b97e824502
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      npm/ng-packs/packages/core/src/lib/utils/file-utils.ts
  2. 1
      npm/ng-packs/packages/core/src/lib/utils/index.ts

20
npm/ng-packs/packages/core/src/lib/utils/file-utils.ts

@ -0,0 +1,20 @@
export function downloadBlob(blob: Blob, filename: string) {
const blobUrl = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = blobUrl;
link.download = filename;
document.body.appendChild(link);
link.dispatchEvent(
new MouseEvent('click', {
bubbles: true,
cancelable: true,
view: window,
}),
);
document.body.removeChild(link);
}

1
npm/ng-packs/packages/core/src/lib/utils/index.ts

@ -3,6 +3,7 @@ export * from './common-utils';
export * from './date-utils';
export * from './environment-utils';
export * from './factory-utils';
export * from './file-utils';
export * from './form-utils';
export * from './generator-utils';
export * from './initial-utils';

Loading…
Cancel
Save