We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
Peter G.7
11 years agoNew member | Level 2
Cannot download a file from Dropbox to the iPad (uploads just fine) - in Swift.
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
Replies have been turned off for this discussion
- Peter G.711 years agoNew member | Level 2
Sorry.....one mistake: in the self.restClient.loadFile, "path" should read "dropboxPath"
- Greg-DB11 years ago
Dropbox Community Moderator
There are a few things that might cause delegate methods to not be called:
- Your rest client is nil or is being released (e.g., by ARC) prematurely.
- You're making the call in a background thread that doesn't have a run loop.
- 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:
- Peter G.711 years agoNew 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,
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!