Dropbox API检查文件是否已更新

时间:2013-03-05 18:44:02

标签: ios xcode dropbox

我正在搜索一些方法来检查何时在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是正确的解决方案。

1 个答案:

答案 0 :(得分:0)

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