我试图使用以下几行代码将一个大文件上载到iCloud:
-(void)uploadFileWithFilePath:(NSString *)Path toFileURLInCloud:(NSURL *)destURL{
NSURL * filePath = [NSURL URLWithString:Path];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void)
{
NSFileCoordinator* fileCoordinator = [[NSFileCoordinator alloc] initWithFilePresenter:nil];
[fileCoordinator coordinateReadingItemAtURL:filePath
options:NSFileCoordinatorReadingWithoutChanges
error:nil
byAccessor:^(NSURL *newURL)
{
NSFileManager * fileManager = [[NSFileManager alloc] init];
NSError * error;
BOOL success = [fileManager copyItemAtURL:filePath toURL:destURL error:&error];
if (success) {
NSLog(@"Copied %@ to %@", filePath, destURL);
}
else {
NSLog(@"Failed to copy %@ to %@: %@", filePath, destURL, error.localizedDescription);
}
}];
});
}我知道这个错误
The operation couldn’t be completed. (Cocoa error 262.)这里有什么问题吗?
发布于 2013-08-21 11:12:45
我刚刚替换了这行代码:
BOOL success = [fileManager copyItemAtURL:filePath toURL:destURL error:&error];关于以下几个方面:
BOOL success = [fileManager setUbiquitous:YES itemAtURL:filePath destinationURL:destURL error:&error];问题解决了。:)
发布于 2013-08-21 11:07:04
好吧,web似乎认为这通常是通过使用字符串路径初始化url引起的。我建议改变这一点:
NSURL * filePath = [NSURL URLWithString:Path];对此:
NSURL * filePath = [NSURL fileURLWithPath:Path];https://stackoverflow.com/questions/18355668
复制相似问题