qgustavor / mega

Unofficial JavaScript SDK for MEGA
https://mega.js.org/
MIT License
161 stars 43 forks source link

Download folder as zip #114

Closed felix2056 closed 2 years ago

felix2056 commented 2 years ago

Can you write a code snippet that zips a folder (My Directory) containing multiple mp4 files and then downloads the zipped file as my-directory.zip?

I tried this but didn't get the best results

file.on('data', (data) => {
        // zip file
        const blob = new Blob([data], { type: 'application/zip' })
        const url = window.URL.createObjectURL(blob)

        // download zip file
        const a = document.createElement('a')
        a.href = url
        a.download = folder.name
        a.click()
});