Supports certificate downloads, wildcard domains, and more.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import JSZip from "jszip";
|
||||
|
||||
export function readFileContent(file: File): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
@@ -15,3 +17,24 @@ export function readFileContent(file: File): Promise<string> {
|
||||
reader.readAsText(file);
|
||||
});
|
||||
}
|
||||
|
||||
export type CustomFile = {
|
||||
name: string;
|
||||
content: string;
|
||||
};
|
||||
|
||||
export const saveFiles2ZIP = async (zipName: string, files: CustomFile[]) => {
|
||||
const zip = new JSZip();
|
||||
|
||||
files.forEach((file) => {
|
||||
zip.file(file.name, file.content);
|
||||
});
|
||||
|
||||
const content = await zip.generateAsync({ type: "blob" });
|
||||
|
||||
// Save the zip file to the local system
|
||||
const link = document.createElement("a");
|
||||
link.href = URL.createObjectURL(content);
|
||||
link.download = zipName;
|
||||
link.click();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user