- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在使用 Core API 将 Dropbox 与 iOS 应用集成。我能够验证一个帐户,并成功上传文件。
但是说在身份验证之后,用户从 dropbox 帐户中删除了 app 文件夹,或者通过 dropbox 设置卸载了应用。
之后,如果我尝试上传文件,整个文件都会上传(进度从 0 到 1),然后我收到错误代码 -1021
对应于 NSURLErrorRequestBodyStreamExhausted
,根据 https://www.dropbox.com/developers/core/api 中的标准 API 错误,也不是错误代码 401
.
问题是这种情况发生在装有 iOS 6 的设备上,即使该帐户本身也没有取消链接。我有一台装有 iOS 5 的设备,它收到错误代码 401
(但在整个文件上传后也是如此),这是核心 api 文档中解释的身份验证错误(错误代码 401) .并且该帐户会自行取消链接。
更新:此错误已在最新的 dropbox core api Build 中解决。
最佳答案
以下代码将在您的应用启动时立即请求用户 Dropbox 帐户信息(如果他们当前已链接)。如果用户删除应用程序文件夹,或从 Dropbox.com 撤消对您的应用程序的访问权限,则当您的应用程序启动时,用户将立即取消链接。我认为这是一个很好的做法,无论 SDK 是否存在上传文件时无法返回 401 的错误。
将此添加到您的应用委托(delegate) didFinishLaunchingWithOptions
您初始化 Dropbox 的方法
DBSession* dbSession = [[[DBSession alloc] initWithAppKey:DROPBOX_KEY appSecret:DROPBOX_SECRET root:kDBRootAppFolder] autorelease];
[DBSession setSharedSession:dbSession];
if ([[DBSession sharedSession] isLinked]) {
DBRestClient* dbRestClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
[dbRestClient setDelegate:self];
[dbRestClient loadAccountInfo];
}
然后将以下方法添加到您的应用委托(delegate)
- (void)restClient:(DBRestClient*)client loadAccountInfoFailedWithError:(NSError*)error {
if (error.code == 401) {
[[DBSession sharedSession] unlinkAll];
}
}
关于ios - Dropbox - 应用程序文件夹已删除 - 出现 NSURLErrorRequestBodyStreamExhausted 错误 - iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15637418/
我正在使用 Core API 将 Dropbox 与 iOS 应用集成。我能够验证一个帐户,并成功上传文件。 但是说在身份验证之后,用户从 dropbox 帐户中删除了 app 文件夹,或者通过 dr
我是一名优秀的程序员,十分优秀!