如何使Dropbox的下载任务失效
How to Invalidate downloading task of Dropbox
我使用 Pods "pod 'ObjectiveDropboxOfficial'" 集成了 Dropbox
我请求特定的下载文件,如以下代码
DBUserClient *client = [DBClientsManager authorizedClient];
[[[client.filesRoutes downloadData:imagePath]
setResponseBlock:^(DBFILESFileMetadata *result, DBFILESDownloadError *routeError, DBRequestError *error, NSData *fileData) {
if (result) {
NSLog(@"File Downloaded")
[[SingletonSDK sharedInstance] hideProgessHud];
}
}] setProgressBlock:^(int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite) {
if (!isCancelButtonAlreadyAppear) {
[[SingletonSDK sharedInstance] showCancelButton:self];
isCancelButtonAlreadyAppear = true;
} }];
下载页面有取消按钮,所以当用户点击取消时应该取消。我确实喜欢跟随获得共享 urlsession 然后失效,因为我没有在 Dropbox Documentation
上找到任何取消下载或使下载失效的方法
- (void)cancelButtonPressedProgressHud {
[[SingletonSDK sharedInstance] hideProgessHud];
NSURLSession * sharedURLSession = NSURLSession.sharedSession;
[sharedURLSession invalidateAndCancel];
}
我也试过 gist category class 使所有 url 下载会话无效,但没有成功。
如果有人遇到或知道如何停止从 Dropbox 下载的文件,敬请谅解。
提前致谢。
您可以使用 DBTask -cancel
在 Dropbox API v2 Objective-C SDK 中取消单个下载任务。例如,它看起来像:
DBDownloadDataTask *req = [client.filesRoutes download...
[req cancel];
我使用 Pods "pod 'ObjectiveDropboxOfficial'" 集成了 Dropbox 我请求特定的下载文件,如以下代码
DBUserClient *client = [DBClientsManager authorizedClient];
[[[client.filesRoutes downloadData:imagePath]
setResponseBlock:^(DBFILESFileMetadata *result, DBFILESDownloadError *routeError, DBRequestError *error, NSData *fileData) {
if (result) {
NSLog(@"File Downloaded")
[[SingletonSDK sharedInstance] hideProgessHud];
}
}] setProgressBlock:^(int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite) {
if (!isCancelButtonAlreadyAppear) {
[[SingletonSDK sharedInstance] showCancelButton:self];
isCancelButtonAlreadyAppear = true;
} }];
下载页面有取消按钮,所以当用户点击取消时应该取消。我确实喜欢跟随获得共享 urlsession 然后失效,因为我没有在 Dropbox Documentation
上找到任何取消下载或使下载失效的方法- (void)cancelButtonPressedProgressHud {
[[SingletonSDK sharedInstance] hideProgessHud];
NSURLSession * sharedURLSession = NSURLSession.sharedSession;
[sharedURLSession invalidateAndCancel];
}
我也试过 gist category class 使所有 url 下载会话无效,但没有成功。
如果有人遇到或知道如何停止从 Dropbox 下载的文件,敬请谅解。 提前致谢。
您可以使用 DBTask -cancel
在 Dropbox API v2 Objective-C SDK 中取消单个下载任务。例如,它看起来像:
DBDownloadDataTask *req = [client.filesRoutes download...
[req cancel];