为什么我在尝试使用 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]; 

我先检查以确保文件存在,然后再上传。我收到这个错误

[WARNING] DropboxSDK: error making request to /1/files_put/sandbox/YourFolder/5iG8y0.m4v -
(-1005) Error Domain=NSURLErrorDomain Code=-1005 "The operation couldn’t be completed. (NSURLErrorDomain error -1005.)"
UserInfo=0x17007c800
{sourcePath=/var/mobile/Containers/Data/Application/CC02A2FC-7B5D-435C-9F81-8A678FF61146/Documents/Movie.m4v, destinationPath=/YourFolder/5iG8y0.m4v}

我不太确定错误是从哪里来的...我再次上传了一张图片,我用一个非常小的视频进行了测试,以确保这不是文件大小问题。我被难住了。

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

一个解决方案是再次调用您发现此类错误的同一函数。在设备中

if (error.code == -1005)
{
    //Again Call the Same Function
    [Function APICallPostWithName:actionName withRequestParameters:dict block:block];
}
                                                                 

重新启动模拟器解决了我的问题。

iOS Simulator -> Reset Content and Settings -> Press Reset (on the warning which will come)

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