Skip to content
Gustavo Rodrigues edited this page Jan 4, 2017 · 10 revisions

Quick start:

import {createWriteStream} from 'fs'
import {File} from 'mega'

const file = File.fromURL('https://mega.nz/#!MAsFwa4b!d8o1uz6SffMAATSQmERLIYITkyc-eTbKQ6xqI3IQSms')

file.loadAttributes((error, file) => {
  console.log(file.name) // big-buck-bunny_trailer.webm
  console.log(file.size) // 2.1MB (in bytes)

  file.download().pipe(createWriteStream(file.name))
})

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

Implementation notes:

Clone this wiki locally