gpt4 book ai didi

ios - xCode Dropbox (400) 错误

转载 作者:行者123 更新时间:2023-11-29 02:50:14 30 4
gpt4 key购买 nike

我在使用 iOS 保管箱 API 登录后尝试将 pdf 发送到我的个人保管箱帐户时遇到错误。

报错如下“[WARNING] DropboxSDK:向/1/files_put/kDBRootAppFolder/Music.pdf 发出请求时出错 - (400) Expected 'root' to be 'dropbox', 'sandbox', or 'auto', got u'kDBRootAppFolder'"

这是我在我的 Xcode iOS 项目中设置保管箱所做的工作。

在我的 didFinishLaunchingWithOptions 中的 AppDelegate.m 中,我有以下内容:

DBSession *dbSession = [[DBSession alloc]
initWithAppKey:@"MYDROPBOXAPPKEY"
appSecret:@"MYDROPBOXAPPSECRET"
root:@"kDBRootAppFolder"]; // either kDBRootAppFolder or kDBRootDropbox
[DBSession setSharedSession:dbSession];

我还在 AppDelegate.m 中添加了以下内容:

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
sourceApplication:(NSString *)source annotation:(id)annotation {
if ([[DBSession sharedSession] handleOpenURL:url]) {
if ([[DBSession sharedSession] isLinked]) {
NSLog(@"App linked successfully!");
// At this point you can start making API calls
}
[[NSNotificationCenter defaultCenter]
postNotificationName:@"isDropboxLinked"
object:[NSNumber numberWithBool:[[DBSession sharedSession] isLinked]]];


return YES;
}
// Add whatever other url handling code is requires here if applicale
return NO;
}

在我的 ViewController.m 中,我添加了以下内容并将其链接到 UIButton

- (void)didPressLink {
if (![[DBSession sharedSession] isLinked]) {
[[DBSession sharedSession] link];
}
}

我的 viewDidLoad 中也有这个

self.restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
self.restClient.delegate = self;

我能够点击我的按钮,收到 Dropbox 登录屏幕并使用我的个人帐户凭据成功登录。当我成功登录时,我收到以下 NSLog 响应“App linked successfully!”请参阅 AppDelegate.m 中具有此 NSLog 语句的上面的代码。到目前为止一切顺利(我认为)

现在我有一个按钮可以创建一个我想发送到保管箱的 pdf。 pdf创建成功。现在我有了将文件发送到保管箱的代码(文件名是我的 pdf 的名称,在这种情况下恰好称为 Music.pdf)

// Upload file to Dropbox
NSString *destDir = @"/";
[self.restClient uploadFile:fileName toPath:destDir withParentRev:nil fromPath:localPath];

这是我收到“DropboxSDK:向/1/fileops/delete 发出请求时出错 - (400) Expected 'root' to be 'dropbox', 'sandbox', or 'auto'; got 'kDBRootAppFolder '"为什么我错过了什么?

注意:一旦我使用我的个人凭据成功登录并收到此错误,如果我回到我的 AppDelegate.m 并将根从 kDBRootAppFolder 更改为沙箱并再次运行该应用程序并尝试结束发送我的 Music.pdf文件到保管箱它会工作。这不是解决方案,因为如果我断开与个人保管箱登录的连接并尝试再次登录,它不会“应用程序链接成功!”如上所示,如果我将 root 保留为 kDBRootAppFolder。想法?…………

最佳答案

看起来您将 kDBRootAppFolder 作为字符串提供,而不是常量。 Dropbox SDK 定义了 kDBRootAppFolder 常量,以便您将正确的“根”发送到 Dropbox API 本身。

所以,这个:

root:@"kDBRootAppFolder"];

应该是:

root:kDBRootAppFolder];

关于ios - xCode Dropbox (400) 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24638591/

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