Skip to content

Download folder as zip #115

Answered by qgustavor
felix2056 asked this question in Q&A
Aug 31, 2022 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

Look, this is not StackOverflow, but I guess what you're trying to implement is something like this:

import { File } from 'https://cdn.skypack.dev/megajs'
import JSZip from 'https://cdn.skypack.dev/jszip'
import saveAs from 'https://cdn.skypack.dev/file-saver'

const folder = File.fromURL('link to some folder') // you can also load it from your account
await folder.loadAttributes() // this is not needed if you load from your account

const handleFolder = async (megaFolder, zipFolder) => {
  if (!megaFolder.children) return
  for (const file of megaFolder.children) {
    if (file.directory) {
      await handleFolder(file, zip.folder(file.name))
    } else {
      zip.file(file.name, await f…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@felix2056
Comment options

@felix2056
Comment options

@qgustavor
Comment options

Answer selected by felix2056
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #114 on August 31, 2022 01:34.