我使用Pods集成了Dropbox
“pod‘ObjectiveDropbox官方’”
我请求特定的下载文件,如以下代码
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下载的文件,请谅解。
事先谢谢。