【问题标题】:Why am I getting a 1005 error when trying to upload to dropbox using the iOS SDK为什么我在尝试使用 iOS SDK 上传到 Dropbox 时收到 1005 错误
【发布时间】:2015-11-10 03:39:53
【问题描述】:

我正在尝试使用 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。)”
用户信息=0x17007c800
{sourcePath=/var/mobile/Containers/Data/Application/CC02A2FC-7B5D-435C-9F81-8A678FF61146/Documents/Movie.m4v,destinationPath=/YourFolder/5iG8y0.m4v}

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

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

【问题讨论】:

  • @Christer 我看到了这篇文章,但这与模拟器有关,而不是设备,我再次在设备上收到此错误
  • 另一个奇怪的事情......当我在调用前放置一个断点,以便应用程序暂停一秒钟,它工作......对我来说没有意义

标签: ios objective-c dropbox dropbox-api


【解决方案1】:

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

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

【讨论】:

  • 我实际上是在设备上而不是模拟器上测试它
猜你喜欢
  • 2022-01-26
  • 1970-01-01
  • 2021-06-21
  • 2021-12-15
  • 1970-01-01
  • 2013-05-25
  • 1970-01-01
  • 2013-01-16
  • 1970-01-01
相关资源
最近更新 更多