gpt4 book ai didi

ios - Dropbox - 应用程序文件夹已删除 - 出现 NSURLErrorRequestBodyStreamExhausted 错误 - iOS

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:44:08 26 4
gpt4 key购买 nike

我正在使用 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com