how can I cancel a file download in progress through the API? thanks.
Unfortunately the SwiftyDropbox SDK doesn't currently offer a way to cancel uploads, but I'll pass this along as a feature request.
thanks, so no cancel for downloads or uploads?
Oh, apologies, I meant to say downloads. But that's correct, there isn't currently a way to cancel either.
This seems to me like a huge oversight from your part. When can we expect an api fix as we have a release coming soon? Without a way to cancel a download this SDK is not suitable for displaying a list of thumbnails in a tableview/collectionview without firing a ton of download requests with no way of stopping them when the cells get out of view.
We integrated this api and now we see that we have to remove it.
I propose to either expose the NSURLRequest directly or to use something similar to Apple's Photos api where a request returns an ID, that one can store as the cell's tag or similar, and then provide a function to cancel a request by ID. Then it will all look quite nicely in cellForItemAtIndexPath:
[...]
if cell.tag != 0 {
client?.files.cancelRequest(DropBoxRequestID(cell.tag))
}
cell.tag = Int(client.files.getThumbnail([...])
Thanks for the feedback! I don't have a timeline for when this might be implemented, but I'll be sure to add your vote to the feature request.
By the way, the SDK is open-source, so you can modify it as desired:
https://github.com/dropbox/SwiftyDropbox
Quick follow up here, in the latest versions of SwiftyDropbox, upload/download request objects do now offer a `cancel` method you can call to cancel the request.
Hi, adding to an old thread, but is this implemented for Objective C Library?
When I try to use cancel(), the app crashes with:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'You must override cancel in a subclass'
Thanks!
Okay, that worked for now.
The override issue in 2.0.6 is fixed now in version 3.0.0.
Do we need to explicitly cancel the upload requests, or is it enough to release the objects by setting it to nil? Example, I have
dbUploadTask = client?.files.uploadSessionStart(input: data) dbUploadTask?.response(completionHandler: { [weak self] (result, error) in}
Then is it safe to set the object to nil while upload is in progress? Or is it necessary to call cancel() before setting it to nil?
dbUploadTask = nil
@DS6 If you want to cancel the request, you should explicitly call `cancel`. (I can't guarantee that `nil`ing the object will be sufficient.)