cancel
Showing results for 
Search instead for 
Did you mean: 

Objective-C, Downloading a file - No such file or directory

SOLVED
805 Views
8 Comments
2 Kudos
Highlighted

Objective-C, Downloading a file - No such file or directory

I'm getting an error I don't understand, both files seem correct.

 

I'm trying to download a file, I've firstly produced a list of files from a folder and I've selected one which I'm trying to download. Here's the information from the list. The list is produced from the app folder.

 

File data: {
    "client_modified" = "2016-11-26T18:10:56Z";
    "content_hash" = snip;
    id = "id:5snip";
    name = "2016-November-26 Sat 18-10-55.bg";
    "path_display" = "/2016-November-26 Sat 18-10-55.bg";
    "path_lower" = "/2016-november-26 sat 18-10-55.bg";
    rev = 18c04ebcd7f;
    "server_modified" = "2016-11-26T18:10:57Z";
    size = 516096;
}

 I've been trying to adapt the following example code, with the path of my database file.

 

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *dbPath = [documentsDirectory stringByAppendingPathComponent:@"bc.db"];
    NSURL *outputUrl = [NSURL fileURLWithPath:dbPath];
//        
//        NSFileManager *fileManager = [NSFileManager defaultManager];
//        NSURL *outputDirectory = [fileManager URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask][0];
//        NSURL *outputUrl = [outputDirectory URLByAppendingPathComponent:@"bc.db"];
    
        [[[client.filesRoutes downloadUrl:selectedFile.pathLower overwrite:YES destination:outputUrl]
          setResponseBlock:^(DBFILESFileMetadata *result, DBFILESDownloadError *routeError, DBRequestError *networkError,
                             NSURL *destination) {
              if (result) {
                  NSLog(@"%@\n", result);
                  NSData *data = [[NSFileManager defaultManager] contentsAtPath:[destination path]];
                  NSString *dataStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
                  NSLog(@"%@\n", dataStr);
              } else {
                  NSLog(@"%@\n%@\n", routeError, networkError);
              }
          }] setProgressBlock:^(int64_t bytesDownloaded, int64_t totalBytesDownloaded, int64_t totalBytesExpectedToDownload) {
              NSLog(@"%lld\n%lld\n%lld\n", bytesDownloaded, totalBytesDownloaded, totalBytesExpectedToDownload);
          }];

However I'm getting this error, I'm just not sure what the error is saying or why it's occuring.

 

DropboxClientError[{
    NSError = "Error Domain=NSCocoaErrorDomain Code=4 \"\U201cCFNetworkDownload_jkkasL.tmp\U201d couldn\U2019t be moved to \U201cDocuments\U201d because either the former doesn't exist, or the folder containing the latter doesn't exist.\" 

    UserInfo={NSSourceFilePathErrorKey=/Users/jm/Library/Developer/CoreSimulator/Devices/F8650859-3E9D-4317-93C7-BEAEC0511EB2/data/Containers/Data/Application/837F319D-68AF-444F-988E-4F7471CF792A/Library/Caches/com.apple.nsurlsessiond/Downloads/com.snip.snip/CFNetworkDownload_jkkasL.tmp, 

    NSUserStringVariant=(\n    Move\n), 

    NSDestinationFilePath=/Users/jm/Library/Developer/CoreSimulator/Devices/F8650859-3E9D-4317-93C7-BEAEC0511EB2/data/Containers/Data/Application/837F319D-68AF-444F-988E-4F7471CF792A/Documents/bc.db, 

    NSFilePath=/Users/jm/Library/Developer/CoreSimulator/Devices/F8650859-3E9D-4317-93C7-BEAEC0511EB2/data/Containers/Data/Application/837F319D-68AF-444F-988E-4F7471CF792A/Library/Caches/com.apple.nsurlsessiond/Downloads/com.snip.snip/CFNetworkDownload_jkkasL.tmp, 

    NSUnderlyingError=0x600000240150 {Error Domain=NSPOSIXErrorDomain Code=2 \"No such file or directory\"}}";
}];

Any help appreciated.

 

 

1 Accepted solution

Accepted Solutions
Solution
Dropboxer

Re: Objective-C, Downloading a file - No such file or directory

I suspect you're using an older version of the SDK. Please update to v3.1.1 and let us know if this issue persists.

8 Replies
Solution
Dropboxer

Re: Objective-C, Downloading a file - No such file or directory

I suspect you're using an older version of the SDK. Please update to v3.1.1 and let us know if this issue persists.

Re: Objective-C, Downloading a file - No such file or directory

I am yes, I was hoping to keep iOS 8 support in my app?

I've also seen migrate from v1 to v2 process, would I need to call this also?

Thanks.
Dropboxer

Re: Objective-C, Downloading a file - No such file or directory

The problem with keeping iOS 8 support is that it involves breaking our Dropbox auth flow to some extent, which was why we dropped support in the first place.

 

As I have mentioned elsewhere on the forum, iOS adoption rates are quite low (<3 % of all iOS users). Dropbox on iOS itself requires iOS >= 9 as well.

 

At this point, there's not too much of a workaround I can recommend other than using this buggy (and somewhat broken) version of the SDK, unless you're prepared to drop iOS 8 support.

 

I'm sorry, I wish I could be more helpful.

Re: Objective-C, Downloading a file - No such file or directory

Yeah I guess it's not a big deal dropping iOS8.

 

I'm sure while googling to find answers, I saw some code for migration v1 users to v2. Do I need this?

If so do you know where I might find the required code, can't find it now.

Level 2

Re: Objective-C, Downloading a file - No such file or directory

Thanks Stephen slightly smiling face, I wrestled with this for some time - error implies an invalid path and all I could imagine was I needed a specific combination of root slash prefix, Apps/appname/ prefix, urlencoding of filenames with blanks.  Nothing seemed to work, and the method doc says almost nothing.  So this didn't even work until the 3.1.1 release 2 days ago?  I have to say this is grim for developers who need their apps updated and working in 4 weeks (or is this an iOS 8 only problem?  I was building for iOS 8, switching to 9 now!).  I thought it would be easy, updated my code, started testing, read a directory fine, and began seeing odd problems like this.

Dropboxer

Re: Objective-C, Downloading a file - No such file or directory

Thanks for the feedback, Mark, and apologies for the inconvenience here.

 

This particular issue was fixed about a month ago in v3.0.18, but there have been a few minor improvements since then.

 

Please reach out if you run into any more odd issues, or have any feedback for the SDK.

Level 2

Re: Objective-C, Downloading a file - No such file or directory

Any chance updated version will be available via Pod?

Currently ObjectiveDropboxOfficial intalled as version 3.0.15 and similiar issue preventing from stable download files from dropbox.

Dropboxer

Re: Objective-C, Downloading a file - No such file or directory

@Yuri555: Want to update to v3.3.3?