我有一个应用程序,我将一个简单的 .csv 文件上传到 Dropbox。当我发送文件时,文件上传完美,但未调用 restClient UploadFile 方法。我想用它来向用户显示文件已成功上传。我似乎记得在我运行代码的前几次调用它,但后来它停止了,我不明白为什么。
以下是一些片段:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0) //Cancel
{
}
else if (buttonIndex == 1) //Send
{
NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *CCD = [docPath stringByAppendingPathComponent:@"CCD.csv"];
if ([[NSFileManager defaultManager] fileExistsAtPath:CCD])
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *machineName = [defaults objectForKey:@"machineName"];
NSString *fileTitle = [defaults stringForKey:@"setTitle"];
NSMutableString *filePath = [NSMutableString string];
[filePath appendString:docPath];
[filePath appendString:@"/CCD.csv"];
NSString *destDir = @"/";
[SVProgressHUD showWithStatus:[NSString stringWithFormat:@"Sending to %@...", machineName]];
[[self restClient] uploadFile:fileTitle toPath:destDir
withParentRev:nil fromPath:filePath];
}
}
}
- (void)restClient:(DBRestClient*)restClient uploadedFile:(NSString*)filePath {
NSLog(@"File uploaded successfully");
[SVProgressHUD dismiss];
};
正如我所说,它完美地上传了文件,我只是没有调用 uploadFile 方法。