tonistiigi / mega

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

getting download url #39

Open stanleynguyen opened 7 years ago

stanleynguyen commented 7 years ago

I'm trying to figure out the download link from the response object I got by uploading a new file but I couldn't. The downloadId and key seem to be undefined so I'm quite lost on how I can get the download url to save to my db for later use. Would you mind helping me with this? Thanks. Below is the object i obtained in the callback from a new file upload.

File {
  downloadId: undefined,
  key: <Buffer 9a 7d d4 64 60 b3 dc 0e 9a af b7 57 bf bb 2e a2 20 d9 db 9e 4b 5f 4e 4e 26 5b c4 03 0c 84 0c 50>,
  api:
   API {
     keepalive: true,
     counterId: 5475797859,
     sid: 'oslNTjWt9ILEYYLtR4Dc-2lGb0pDRGhzUkJFb-6ZCNSQHyOOQGxpN7jRnw',
     _events: { sc: [Function] },
     _eventsCount: 1,
     sn:
      Request {
        domain: null,

        _events: [Object],
        _eventsCount: 3,
        _maxListeners: undefined,
        method: 'POST',
        callback: [Function],
        readable: true,
        writable: true,
        explicitMethod: true,
        _qs: [Object],
        _auth: [Object],
        _oauth: [Object],
        _multipart: [Object],
        _redirect: [Object],
        _tunnel: [Object],
        headers: [Object],
        setHeader: [Function],
        hasHeader: [Function],
        getHeader: [Function],
        removeHeader: [Function],
        localAddress: undefined,
        pool: {},
dests: [],
        __isRequestRequest: true,
        _callback: [Function],
        uri: [Object],
        proxy: null,
        tunnel: false,
        setHost: true,
        originalCookieHeader: undefined,
        _disableCookies: true,
        _jar: undefined,
        port: 80,
        host: 'w.api.mega.co.nz',
        path: '/A3k5qdmo5J6l_LRm6QNp7gcSRAE',
        httpModule: [Object],
        agentClass: [Object],
        agent: [Object],
        _started: true,
        href: 'http://w.api.mega.co.nz/A3k5qdmo5J6l_LRm6QNp7gcSRAE',
        req: [Object],
        ntick: true } },
  nodeId: 'TU0G0BzB',
  timestamp: 1483193929,
  type: 0,
  directory: false,
  size: 139775,
  attributes: { n: 'all_monster_are_human_hd_wallpaper__by_lupussmoth-d927b79.png' },
  name: 'all_monster_are_human_hd_wallpaper__by_lupussmoth-d927b79.png',
  parent:
   File {
     downloadId: undefined,
     key: undefined,
    api:
      API {
        keepalive: true,
        counterId: 5475797859,

        sid: 'oslNTjWt9ILEYYLtR4Dc-2lGb0pDRGhzUkJFb-6ZCNSQHyOOQGxpN7jRnw',
        _events: [Object],
        _eventsCount: 1,
        sn: [Object] },
     nodeId: 'fUdlEASK',
     timestamp: 1483187895,
     type: 2,
     directory: true,
     name: 'Cloud Drive',
     children:
      [ [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Circular] ] } }