我正在尝试使用以下代码行将大文件上传到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);
}
}];
});
}
Run Code Online (Sandbox Code Playgroud)
我收到这个错误
The operation couldn’t be completed. (Cocoa error 262.)
Run Code Online (Sandbox Code Playgroud)
这可能是什么问题?
Mic*_*lum 16
好吧,网络似乎认为这通常是由你用字符串路径初始化url引起的.我建议改变这个:
NSURL * filePath = [NSURL URLWithString:Path];
Run Code Online (Sandbox Code Playgroud)
对此:
NSURL * filePath = [NSURL fileURLWithPath:Path];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2332 次 |
| 最近记录: |