0

I'm trying to use the Dropbox iOS sdk to upload a small video file. I've had success with images, but the video upload seems to be failing. My code to upload the video is as follows

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

I'm checking first just to make sure the file exists and then uploading. I'm getting this error

[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}

I'm not really sure where the error is coming from ... again I was able to upload an image, and I tested with a very small video to make sure it was not a file size issue. I'm stumped.

Just as a note, this is not happening on the simulator, it's happening on the device, so resetting the simulator will not solve the problem

user379468
  • 3,989
  • 10
  • 50
  • 68
  • possible duplicate of [NSURLErrorDomain Error Code -1005](http://stackoverflow.com/questions/26391189/nsurlerrordomain-error-code-1005) – Christer Aug 17 '15 at 13:24
  • @Christer I saw this post, but this pertains to the simulator and not the device, again I'm getting this error on the device – user379468 Aug 17 '15 at 21:55
  • another strange thing ... when I place a breakpoint in front of the call, so that the app pauses for a second, it works .... makes no sense to me why – user379468 Aug 18 '15 at 01:46

1 Answers1

0

one solution is again call the Same Function in which you fot such error. in Device

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

Restarting the simulator fixed the issue for me.

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

enter image description here

enter image description here

-(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];
}
Community
  • 1
  • 1
Mehul
  • 3,033
  • 23
  • 37