0

我正在寻找某种方法来检查文件何时在 Dropbox 上更新以告知用户。我发现最好的是属于 Sync API 的代码片段,它观察是否有任何变化:

// First, create a file for you to change
DBPath *path = [[DBPath root] childPath:@"change-me.txt"];
self.file = [[DBFilesystem sharedFilesystem] createFile:path error:nil];

// Next, register for changes on that file
[self.file addObserver:self block:^() {

// This block will be called every time your file changes

// if newerStatus is not nil, it means a newer version is available
DBFileStatus *newerStatus = file.newerStatus;
if (newerStatus) {

if (!newerStatus.cached) {
NSLog(@"newerStatus.cached == NO; this means the file downloading");
} else {

// Update to the newly available version and print it out
[file update:nil];
NSLog(@"The file is done downloading: %@", [file readString:nil]);
}
}
}];

有任何想法吗?我实际上是想添加 Sync api 只是为了使用此功能,但我不认为添加两个 Dropbox SDK 是正确的解决方案。

4

1 回答 1

0

我推荐使用 Sync API,我们正在努力确保 Core API 的大部分功能都可以使用 Sync API。否则,您可以使用实际为 Sync API 提供支持的 REST API的/delta 端点。

于 2013-03-09T20:25:35.633 回答