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: 

Cache files properly with Core API for iOS and Swift

Cache files properly with Core API for iOS and Swift

vanya e.
New member | Level 1

Hello!

I'm now working on the simple Dropbox viewer application.
Currently I'm using "download to Documents folder" method like that: 

if let data =  NSData(contentsOfFile: destinationPath) {

            print("File already cached")

 } else {

            print("File not cached, processing cache operation...")

            Manager.client.loadFile(filePath, intoPath: destinationPath)

  }

Files are downloading properly, but, I think, that it's a wrong way to cache files. 
So, the question is: is there a way to cache images with standard API tools and, for example, store them with NSCache or something similar?

P.S. It's not essentially important, actually, in which programming language will be answer, I'm simply trying to understand the principles, if they exist

Thanks!

1 Reply 1

Greg-DB
Dropbox Staff

The Dropbox API and SDK themselves don't offer local caching like this, so you will need to implement it in your app's code if your app needs caching. Actual caching strategies and algorithms are beyond the scope of just Dropbox/Dropbox API support, so I can't offer much help with that in general. Perhaps someone here can offer some advice or direct you to some good resources though.

One thing I will note specific to Dropbox though, is to check the rev for the value. The remote Dropbox file could have changed after you originally downloaded it, meaning the copy you have locally is out of date.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?