Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't Download File From Dropbox #109

Closed
j-cimb-barker opened this issue Mar 16, 2017 · 4 comments
Closed

Can't Download File From Dropbox #109

j-cimb-barker opened this issue Mar 16, 2017 · 4 comments

Comments

@j-cimb-barker
Copy link

Hello,

I am using the following code to download files using the Vs2 API:

[[client.filesRoutes downloadData:filePath]
    setResponseBlock:^(DBFILESFileMetadata *result, DBFILESDownloadError *routeError, DBRequestError *error,
                       NSData *fileContents) {
      if (result) {
        NSLog(@"%@\n", result);
        NSString *dataStr = [[NSString alloc] initWithData:fileContents encoding:NSUTF8StringEncoding];
        NSLog(@"%@\n", dataStr);
      } else {
        NSLog(@"%@\n%@\n", routeError, error);
      }
    }];

I receive the error:

2017-03-16 15:58:35.759 xctest[78431:5712864] (null)
DropboxClientError[{
    NSError = "Error Domain=NSURLErrorDomain Code=-1 \"unknown error\" UserInfo={NSErrorFailingURLKey=https://api-content.dropbox.com/2/files/download, NSLocalizedDescription=unknown error, NSErrorFailingURLStringKey=https://api-content.dropbox.com/2/files/download}";
}];

I have checked and the file at filePath exists. Is there anything I am missing...?

Kind regards,

Joel

@greg-db
Copy link
Contributor

greg-db commented Mar 16, 2017

[Cross-linking for reference: https://www.dropboxforum.com/t5/API-support/Can-t-Download-File-From-Dropbox-downloadData-With-Objective-C/m-p/211957#M10699 ]

Thanks for the report. I unfortunately can't reproduce this error though, and your code looks correct.

The error message itself is unfortunately also not very helpful, as it seems to be a catch-all error for unknown NSURL issues:

Returned when the URL Loading system encounters an error that it cannot interpret.

You mentioned that you're seeing this for both uploading and downloading, but not other calls. Uploading and downloading use api-content.dropbox.com whereas most other calls use api.dropbox.com. Is there anything on your network connection (firewall, anti-virus, proxy, etc.) that may be interfering with api-content.dropbox.com but not api.dropbox.com? (E.g., perhaps one is whitelisted somewhere but the other isn't.)

@j-cimb-barker
Copy link
Author

Hello, Thanks for replying. I think it's because I am using a token obtained from the App Web Console during testing. I am switching to obtaining the token via the App. I will let you know if this improves the issue.

@greg-db
Copy link
Contributor

greg-db commented Mar 17, 2017

Access tokens acquired via the App Console or via the app's authorization flow should be functionality equivalent. Let us know what you find though.

@j-cimb-barker
Copy link
Author

I found out this was due to the way I was setting up DBUserClient. I switched to:

DBUserClient *client = [DBClientsManager authorizedClient];

and it solved the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants