Skip to main content
Version: 1.0

File downloading

You can try by running this code at your console:

deno run https://mega.js.org/demos/downloading-demo.js
import { getLoggedInStorage } from './logging-in-demo.js'
const storage = await getLoggedInStorage()

console.log('Choose one of the following files:')
console.log(storage.root.children.filter(e => !e.children).map(e => e.name))

const filename = prompt('Enter a file name (case sensitive):')
const file = storage.find(filename)
if (!file) throw Error('File not found!')

const data = await file.downloadBuffer()
await Deno.writeFile(file.name, data)