Mega

Unofficial Node.js SDK for Mega / Demo page

View on GitHub View on NPM
This page is only for testing purposes and you should only use test files.

Access file by URL:

Name:
Size: B
Download


mega.file(url).loadAttributes(function(err, file) {
  // file.name
  // file.size
  // file.attributes
})

Access file manager

Login
Providing e-mail and password is optional.
Rename, move, delete and add files in another window to see this list change in realtime.

var storage = mega.storage({email: '', password: ''}, function(err) {
  // storage.files
  // storage.mounts
})

Link to file


file.link(function(err, url) {
  // url: https://mega.co.nz/#!downloadId!key
})

Download file


file.download().pipe(fs.createWriteStream('myfile.txt'))

file.download(function(err, data) {
  // data is buffer
})

Upload file


fs.createReadStream('myfile.txt').pipe(storage.upload('myfile.txt'))

storage.upload({name: 'myfile.txt'}, buffer, function(err, file) {

})