cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Upload progress Nodejs API

Upload progress Nodejs API

theophilepace
Explorer | Level 3
Go to solution

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

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution
One alternative would be to switch to using "upload sessions", where you upload files in pieces. You could then keep track of how much you've uploaded between each piece:

https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUploadSessionStart
https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUploadSessionAppendV2
https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUploadSessionFinish

That's a good bit more work though. Otherwise, I'm afraid I don't have a workaround to offer.

View solution in original post

4 Replies 4

Greg-DB
Dropbox Staff
Go to solution
No, unfortunately there isn't a good solution here. The filesListFolder call will only return the newly uploaded file once it finishes uploading. The API doesn't offer information on uploads that are in progress.

I'll send this along as a feature request for a way to receive progress information for uploads.

theophilepace
Explorer | Level 3
Go to solution

Hello Greg,

 

Thank you for the information. Well, that would be a really good feature to implement, especially for long transfers.

 

Is there anyway or workaround to get an estimation or something ?

 

 

Greg-DB
Dropbox Staff
Go to solution
One alternative would be to switch to using "upload sessions", where you upload files in pieces. You could then keep track of how much you've uploaded between each piece:

https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUploadSessionStart
https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUploadSessionAppendV2
https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUploadSessionFinish

That's a good bit more work though. Otherwise, I'm afraid I don't have a workaround to offer.

theophilepace
Explorer | Level 3
Go to solution

Hello Greg,

 

thank you for your answer.

 

I think I will implement that in my application, it also looks safer than 1 file upload. 

 

Regards,

 

Théophile

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    theophilepace Explorer | Level 3
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?