cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Cannot download a file from Dropbox to the iPad (uploads just fine) - in Swift.

Cannot download a file from Dropbox to the iPad (uploads just fine) - in Swift.

Peter G.7
New member | Level 2

I have been going around in circles trying to solve this problem. I can send files to Dropbox no problem, but cannot download them. All the delegate methods get called for sending, but the methods for downloading the files do not get called. Specifics: Core API. using Swift. iOS 8.1, using xcode. Checked and rechecked all my code. Follows is my related code:

func xferToLocal() {

    let dirPaths:[String]? = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.AllDomainsMask, true) as? [String]
    let directories:[String] = dirPaths!
    docsDir = directories[0]
    docsDirDAT = docsDir + "/" + filenameDAT
    let dropboxPath = "/" + filenameDAT
    self.restClient.loadFile(path, intoPath:docsDirDAT)
}

func restClient(client:DBRestClient, loadedFile dropboxPath:NSString, contentType:NSString, metadata:DBMetadata) {
    println("File loaded into path: \(docsDirDAT)")
}

func restClient(client:DBRestClient, loadFileFailedWithError error:NSError) {
    println("There was an error loading the file: \(error)")
}

I would appreciate any help.

3 Replies 3

Peter G.7
New member | Level 2

Sorry.....one mistake: in the self.restClient.loadFile, "path" should read "dropboxPath"

Greg-DB
Dropbox Staff

There are a few things that might cause delegate methods to not be called:

  1. Your rest client is nil or is being released (e.g., by ARC) prematurely.
  2. You're making the call in a background thread that doesn't have a run loop.
  3. Your delegate method that should be called back has a typo in it. Unfortunately the SDK doesn't warn you if it can't find a delegate method to call; it just completes without telling anyone.

If none of that seems to be it though, please open an API ticket, with a sample project that reproduces the issue if possible, so we can look into it:

https://www.dropbox.com/developers/contact

Peter G.7
New member | Level 2

As it turn out, the download wasn’t failing at all. I just wasn’t giving dropbox enough time to download the file before I started executing other commands, causing the app to crash. Many thanks to the Dropbox support team. Class act,

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Peter G.7 New member | Level 2
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?