2021-08-30 15:15:43 +01:00
|
|
|
// Copyright (C) 2021 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DownloadTXT is used to download some content as a file.
|
|
|
|
*/
|
|
|
|
export class Download {
|
|
|
|
public static file(content: string, name: string): void {
|
|
|
|
const blob = new Blob([content], {type: 'text/plain'});
|
2022-04-07 12:04:24 +01:00
|
|
|
const elem = window.document.createElement('a');
|
|
|
|
elem.href = window.URL.createObjectURL(blob);
|
|
|
|
elem.download = name;
|
|
|
|
document.body.appendChild(elem);
|
|
|
|
elem.click();
|
|
|
|
document.body.removeChild(elem);
|
2021-08-30 15:15:43 +01:00
|
|
|
}
|
|
|
|
}
|