繁体   English   中英

为什么尝试使用iOS SDK上传到保管箱时出现1005错误

[英]Why am I getting a 1005 error when trying to upload to dropbox using the iOS SDK

我正在尝试使用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 /容器/数据/应用程序/CC02A2FC-7B5D-435C-9F81-8A678FF61146/Documents/Movie.m4v,destinationPath=/YourFolder/5iG8y0.m4v}

我不太确定错误是从哪里来的。。。我再次能够上传图像,并用很小的视频进行了测试,以确保它不是文件大小的问题。 我很沮丧

请注意,这不是在模拟器上发生的,而是在设备上发生的,因此重置模拟器不会解决问题

一种解决方案是再次调用Same Function,在其中您会遇到此类错误。 在设备中

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];
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM