Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

theophilepace's avatar
theophilepace
Explorer | Level 3
9 years ago
Solved

Upload progress Nodejs API

Hello,

 

I am using your API to upload different kind of file through nodeJs.

 

I saw a lot of people explaining the API currently do not support progress bars and monitoring stuff so I've tried to create a workaround.

 

I've implemented this method :

 

monitorTransfer(dbx, fileName, totalSize) {
    console.log('monitoring')
    if (this.continueMonitoring) {
      dbx.filesListFolder({ path: "" }).then((data) => {
        const fileMetadata = data.entries.filter(f => f.name == fileName)
        console.log(fileMetadata)
        // console.log(`uploaded ${fileMetadata.size} on ${totalSize} ==> ${fileMetadata.size / totalSize} %`)
        setTimeout(this.monitorTransfer.bind(this), 500, dbx, fileName, totalSize, continueMonitoring)
      })
      .catch((err) => {
        console.log(`[dropboxConnector] error monitoring : `)
        console.log(err)
        setTimeout(this.monitorTransfer.bind(this), 500, dbx, fileName, totalSize)
      })
    }
  }

I call it every 500 ms until the transfer is over. I have the following problem: 

my file only appears once the transfer is completed : 

monitoring
[]
monitoring
[]
monitoring
[]
monitoring
[]
monitoring
[]
monitoring
[]
monitoring
[ { '.tag': 'file',
    name: 'zouzou-test.js',
    path_lower: '/zouzou-test.js',
    path_display: '/zouzou-test.js',
    id: 'id:WW00APcl7lAAAAAAAAAAPQ',
    client_modified: '2017-06-24T16:28:41Z',
    server_modified: '2017-06-24T16:28:41Z',
    rev: '6458a6c857',
    size: 144256468,
    content_hash: '8968034036d4dd13a8b7ea090245585403a37c2db5386dff6c80da3b00d0c137' } ]

Is there someway to detect my file before the transfer is over? How can I make this work?

 

I am OK with using chunk transfer if it helps.

 

Thanks,

 

Théophile

4 Replies

Replies have been turned off for this discussion

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!