我尝试使用Dropbox iOS sdk上传小视频文件。我已成功使用图片,但视频上传似乎失败了。我上传视频的代码如下
NSString *pathToMovie = [[self applicationDocumentsDirectory].path
stringByAppendingPathComponent:@"Movie.m4v"];
NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie];
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:pathToMovie];
if (fileExists) {
NSLog(@"File Exsits");
//open the already downloaded file
}
if (!fileExists) {
NSLog(@"File does not Exsit");
//download and then open
}
[self.restClient
uploadFile:[NSString stringWithFormat:@"%@.m4v", [self randomStringWithLength:6]]
toPath:@"/YourFolder" fromPath:pathToMovie];
我首先检查以确保文件存在然后上传。我收到此错误
[警告] DropboxSDK:向/1/files_put/sandbox/YourFolder/5iG8y0.m4v发出错误请求 -
(-1005)错误域= NSURLErrorDomain代码= -1005"无法完成操作。 (NSURLErrorDomain错误-1005。)"
的UserInfo = 0x17007c800
{sourcePath = / var / mobile / Containers / Data / Application / CC02A2FC-7B5D-435C-9F81-8A678FF61146 / Documents / Movie.m4v,destinationPath = / YourFolder / 5iG8y0.m4v}
我不确定错误来自哪里...我再次上传了一张图片,我测试了一个非常小的视频,以确保它不是文件大小问题。我很难过。
正如笔记一样,这不会发生在模拟器上,它会在设备上发生,因此重置模拟器无法解决问题
答案 0 :(得分:0)
if (error.code == -1005)
{
//Again Call the Same Function
[Function APICallPostWithName:actionName withRequestParameters:dict block:block];
}
iOS模拟器 - >重置内容和设置 - >按重置(在将出现的警告上)
-(void)restClient:(DBRestClient*)client uploadFileFailedWithError:(NSError*)error {
NSLog(@"File upload failed with error - %@", error.userInfo);
NSString *myfile=[error.userInfo valueForKey:@"sourcePath"];
[self.restClient uploadFile:@"youfilename" toPath:@"/yourfilepath" withParentRev:nil fromPath:myfile];
}