MCPcopy Create free account
hub / github.com/PaulleDemon/PyUIBuilder / createFilesAndDownload

Function createFilesAndDownload

src/codeEngine/utils.js:8–34  ·  view source on GitHub ↗
(fileDataArray, zipName="untitled")

Source from the content-addressed store, hash-verified

6 * @param {[]} fileDataArray - [{fileData: "", fileName: "", folder: ""}]
7 */
8export async function createFilesAndDownload(fileDataArray, zipName="untitled"){
9
10 const zip = new JSZip()
11
12 fileDataArray.forEach(file => {
13 const { fileData, fileName, folder } = file
14
15 // If a folder is specified, create it if it doesn't exist
16 if (folder) {
17 const folderRef = zip.folder(folder)
18 folderRef.file(fileName, fileData)
19
20 } else {
21 // If no folder is specified, place the file in the root
22 zip.file(fileName, fileData)
23 }
24 })
25
26 // Generate the ZIP asynchronously
27 zip.generateAsync({ type: "blob" }).then(function(content) {
28 const link = document.createElement("a")
29 link.href = URL.createObjectURL(content)
30 link.download = `${zipName}.zip`
31 link.click()
32 })
33
34}

Callers 2

generateTkinterCodeFunction · 0.90
generateCustomTkCodeFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected