Skip to content
Gustavo Rodrigues edited this page Jan 2, 2018 · 10 revisions

Quick start:

import { File } from 'megajs'

const file = File.fromURL('some file url')

file.loadAttributes((error, file) => {
  console.log(file.name) // file name
  console.log(file.size) // file size in bytes

  file.download((err, data) => {
    if (err) throw err
    console.log(data.toString()) // file contents
  })
})

Try the example above on CodePen

API documentation:

  • MEGA: the module entry point
  • Storage: creates a logged in connection instance to MEGA
  • File: allows access to shared files and folders
  • MutableFile: extends File allowing to change file metadata

Other pages

Clone this wiki locally