Access file by URL:
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
Download from
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) {
})