{"action":"created","issue":{"url":"https://api.github.com/repos/qgustavor/mega/issues/44","repository_url":"https://api.github.com/repos/qgustavor/mega","labels_url":"https://api.github.com/repos/qgustavor/mega/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/qgustavor/mega/issues/44/comments","events_url":"https://api.github.com/repos/qgustavor/mega/issues/44/events","html_url":"https://github.com/qgustavor/mega/issues/44","id":372292551,"node_id":"MDU6SXNzdWUzNzIyOTI1NTE=","number":44,"title":"Fail to upload to MEGA","user":{"login":"joseph1125","id":8279406,"node_id":"MDQ6VXNlcjgyNzk0MDY=","avatar_url":"https://avatars2.githubusercontent.com/u/8279406?v=4","gravatar_id":"","url":"https://api.github.com/users/joseph1125","html_url":"https://github.com/joseph1125","followers_url":"https://api.github.com/users/joseph1125/followers","following_url":"https://api.github.com/users/joseph1125/following{/other_user}","gists_url":"https://api.github.com/users/joseph1125/gists{/gist_id}","starred_url":"https://api.github.com/users/joseph1125/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joseph1125/subscriptions","organizations_url":"https://api.github.com/users/joseph1125/orgs","repos_url":"https://api.github.com/users/joseph1125/repos","events_url":"https://api.github.com/users/joseph1125/events{/privacy}","received_events_url":"https://api.github.com/users/joseph1125/received_events","type":"User","site_admin":false},"labels":[{"id":313402927,"node_id":"MDU6TGFiZWwzMTM0MDI5Mjc=","url":"https://api.github.com/repos/qgustavor/mega/labels/help%20wanted","name":"help wanted","color":"159818","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-10-21T08:42:37Z","updated_at":"2018-10-21T16:42:44Z","closed_at":null,"author_association":"NONE","body":"\r\n\r\n\r\n\r\nWhen I try to upload files to MEGA, the error is indicated as below\r\n\r\nCODE:\r\n```\r\nprivate uploadFile(filePath: string, parentFolder: MutableFile): Promise<Boolean> {\r\n    const fileName = path.basename(filePath);\r\n    return new Promise((resolve, reject) => {\r\n      const readStream = fs.createReadStream(filePath);\r\n      readStream.on('error', error => reject(error));\r\n      readStream.on('end', () => {\r\n        resolve(true);\r\n      });\r\n      readStream.pipe(parentFolder.upload({\r\n        name: fileName,\r\n        size: fs.statSync(filePath).size\r\n      }));\r\n    })\r\n  }\r\n```\r\n\r\nERROR: \r\nc:\\Users\\zx261\\Documents\\projects\\project\\node_modules\\megajs\\dist\\main.node-cjs.js:384\r\n\r\n  key.copy(newKey);\r\n\r\n      ^\r\n\r\n\r\n\r\nTypeError: Cannot read property 'copy' of undefined\r\n\r\n    at unmergeKeyMac (c:\\Users\\zx261\\Documents\\projects\\project\\node_modules\\megajs\\dist\\main.node-cjs.js:384:7)\r\n\r\n    at getCipher (c:\\Users\\zx261\\Documents\\projects\\project\\node_modules\\megajs\\dist\\main.node-cjs.js:308:18)\r\n\r\n    at checkCallbacks (c:\\Users\\zx261\\Documents\\projects\\project\\node_modules\\megajs\\dist\\main.node-cjs.js:1582:7)\r\n\r\n    at streamToCb (c:\\Users\\zx261\\Documents\\projects\\project\\node_modules\\megajs\\dist\\main.node-cjs.js:1789:11)\r\n\r\n    at Request.<anonymous> (c:\\Users\\zx261\\Documents\\projects\\project\\node_modules\\megajs\\dist\\main.node-cjs.js:26:7)\r\n\r\n    at Request.emit (events.js:187:15)\r\n\r\n    at IncomingMessage.<anonymous> (c:\\Users\\zx261\\Documents\\projects\\project\\node_modules\\request\\request.js:1083:12)\r\n\r\n    at Object.onceWrapper (events.js:273:13)\r\n\r\n    at IncomingMessage.emit (events.js:187:15)\r\n\r\n    at endReadableNT (_stream_readable.js:1094:12)"},"comment":{"url":"https://api.github.com/repos/qgustavor/mega/issues/comments/431683972","html_url":"https://github.com/qgustavor/mega/issues/44#issuecomment-431683972","issue_url":"https://api.github.com/repos/qgustavor/mega/issues/44","id":431683972,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMTY4Mzk3Mg==","user":{"login":"qgustavor","id":1020670,"node_id":"MDQ6VXNlcjEwMjA2NzA=","avatar_url":"https://avatars3.githubusercontent.com/u/1020670?v=4","gravatar_id":"","url":"https://api.github.com/users/qgustavor","html_url":"https://github.com/qgustavor","followers_url":"https://api.github.com/users/qgustavor/followers","following_url":"https://api.github.com/users/qgustavor/following{/other_user}","gists_url":"https://api.github.com/users/qgustavor/gists{/gist_id}","starred_url":"https://api.github.com/users/qgustavor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qgustavor/subscriptions","organizations_url":"https://api.github.com/users/qgustavor/orgs","repos_url":"https://api.github.com/users/qgustavor/repos","events_url":"https://api.github.com/users/qgustavor/events{/privacy}","received_events_url":"https://api.github.com/users/qgustavor/received_events","type":"User","site_admin":false},"created_at":"2018-10-21T16:42:44Z","updated_at":"2018-10-21T16:42:44Z","author_association":"OWNER","body":"I was using v8.11.1. I switched to v10.12.0 and tested again some times:\r\n\r\n1. The test script created [this folder](https://mega.nz/#F!0xEmzSAK!DitameOxenteCALVINISTA) then stopped working: for some reason the upload callback wasn't called;\r\n2. The test script created [this folder](https://mega.nz/#F!Ylc2AShJ!AriscaEficazMORFOLOGIA) then the upload finished successfully;\r\n3. The test script created [this folder](https://mega.nz/#F!BtVwXK7T!MunidoAmuadoFLUXOGRAMA) then stopped working again;\r\n4. (now with a sniffer enabled) The test script created [this folder](https://mega.nz/#F!w9dAGQwZ!ChacalGaludoTECNOCRATA) and the upload finished successfully;\r\n5. The test script created [this folder](https://mega.nz/#F!Q4dCGIRD!SurtarEsteioCONJECTURA) then stopped working again. The sniffer shows that four connections were used and the server don't returned the upload \"hash\";\r\n6. The test script created [this folder](https://mega.nz/#F!cx9SmIBQ!AlentoMulataDESVENTURA) and the upload finished successfully;\r\n\r\nI did the following changed on \"mutable-file.js\":\r\n\r\n* De-duplicated chunk verification code;\r\n* Added options to control how chunks work and the maximum number of connections;\r\n* Added a `process.nextTick` so in case some node version calls `checkCallbacks` before `megaEncrypt`.\r\n\r\nThen I tested again:\r\n\r\n1. [It worked](https://mega.nz/#F!Q88yASAT!PrezamDecanoMONOPLEGIA);\r\n2. [It worked](https://mega.nz/#F!l180QCTJ!PuerilCrassoBOQUETEIRA);\r\n3. [It worked](https://mega.nz/#F!V41QEIwC!AlheioAdeptaCONCUNHADA);\r\n4. [It worked](https://mega.nz/#F!o102XCQZ!EmendaPreulaTISIOLOGIA).\r\n\r\nI will publish a new version with those changes, update the master branch and document those new options."}}
{"actor":{"display_login":"qgustavor"}}