tonistiigi / mega

THIS REPO IS NOT MAINTAINED. Unofficial Node.js SDK for Mega
http://tonistiigi.github.com/mega
118 stars 33 forks source link

Cannot upload file to a folder #25

Open chinhodado opened 9 years ago

chinhodado commented 9 years ago

I'm trying to upload a file to a folder:

var folder = mega.file('https://mega.co.nz/#F!rBtmGBLL!EfKQouVq4z1TjzFKI1oerA');
var up = storage.upload({
        name: path.basename(filepath),
        size: fs.statSync(filepath).size, // removing this causes data buffering.
        target: folder
    },
    // fs.readFileSync(filepath),
    function(err, file) {
        if (err) throw err
        console.log('\nUploaded', file.name, file.size + 'B')

        file.link(function(err, link) {
            if (err) throw err
            console.log('Download from:', link)
        })
    })

fs.createReadStream(filepath).pipe(up)

and i got this error:

Error: EARGS (-2): You have passed invalid arguments to this command.
    at Request._callback (C:\Users\chin\node_modules\mega\lib\api.js:69:13)
    at Request.self.callback (C:\Users\chin\node_modules\mega\node_modules\request\request.js:373:22)
    at Request.emit (events.js:98:17)
    at Request.<anonymous> (C:\Users\chin\node_modules\mega\node_modules\request\request.js:1318:14)
    at Request.emit (events.js:117:20)
    at IncomingMessage.<anonymous> (C:\Users\chin\node_modules\mega\node_modules\request\request.js:1266:12)
    at IncomingMessage.emit (events.js:117:20)
    at _stream_readable.js:943:16
    at process._tickCallback (node.js:419:13)