We Want to Hear From You! What Do You Want to See on the Community? Tell us here!
Forum Discussion
manos77
4 years agoExplorer | Level 3
API - How to stop an upload?
Hi there,
I've built an app using the JavaScript SDK where users can upload files to a folder.
Sometimes users are uploading big files eg a few GB and they decide they want to stop uploading the file.
I don't see a method on how to do that - neither with filesUpload nor with filesUploadSessionStart, filesUploadSessionAppendV2, filesUploadSessionFinish methods.
Could you guide me on how to achieve that? I am particularly interested in stopping the chunked uploading
2 Replies
- Greg-DB4 years ago
Dropbox Community Moderator
The Dropbox API v2 JavaScript API v2 SDK doesn't offer the ability to cancel an individual request, but I'll pass this along as a feature request. I can't promise if or when that might be implemented though.
For upload sessions though, since it involves multiple calls, you can stop the process in between any of the individual filesUploadSession* method calls, since you control the execution flow of those; that is, stop making any further such calls when the user indicates they want to cancel.
- manos774 years agoExplorer | Level 3
thanks Greg, that's what I was trying and I finally made it work!
just in case someone bumps on the same issue:
within the upload example there is the following:
const task = workItems.reduce((acc, blob, idx, items) => {
which has three instances of:
return acc.then(function(sessionId) {
what you need to do is add a line in the beginning of all 3 above instances
if( fileUploadShouldBeAborted ) return
obviously, fileUploadShouldBeAborted has to be populated by you somehow
and then you also need to handle the case that the upload has been completed,
which can only be solved by making another call to delete the file
About Discuss Dropbox Developer & API
Make connections with other developers815 PostsLatest Activity: 4 hours ago
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 or Facebook.
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!