We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
bbongrip
8 years agoHelpful | Level 6
search dropbox folder
can anybody tell me a way to search a specific folder in dropbox to populate an array of strings with the filenames in that folder? Im trying to implement a way for users to search for a file in a dr...
- 8 years agoI finally got it! lol Thank you so much for you time and help. It has been greatly appreciated and a learning experience for me. I ended up using "//" as my path and it works perfect.
Cheers!
Kevin
Greg-DB
8 years agoDropbox Staff
Using the Dropbox API, you can search for files and folders under a particular path using the /2/files/search endpoint:
https://www.dropbox.com/developers/documentation/http/documentation#files-search
If you're using an official SDK, there will be a corresponding search method for that.
https://www.dropbox.com/developers/documentation/http/documentation#files-search
If you're using an official SDK, there will be a corresponding search method for that.
- bbongrip8 years agoHelpful | Level 6thanks again greg. however I'm not really understanding how i would be able to search for all the filenames within a specific dropbox folder, and add those filenames to an array of strings, to then use as a base for my user to search for a specific string in that array. sorry if I'm not making to much sense. this is all very new to me. FYI - I'm using swift 3
- Greg-DB8 years agoDropbox Staff
Since you're using Swift, are you using the official SwiftyDropbox SDK? In that case, you'd use the search method in FilesRoutes. As long as the call succeeds, it will return a SearchResult. You can then use the SearchResult.matches, which is an array of SearchMatch. SearchMatch.metadata contains the FileMetadata for the match, which contains the name, pathDisplay, etc.
Give that a try and let us know if you run in to any issues.
- bbongrip8 years agoHelpful | Level 6
I was trying the search func that returns a SearchResult but I couldnt get it working. here is some of my code.
hope this helps. I really appreciate your help
// MARK: - UISearchBarDelegate func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
var data = [String]()
// IN HERE I WANT TO SEARCH MY APPS FOLDER IN DROPBOX AND POPULATE THE "data" STRING ARRAY WITH THE FILE NAMES OF ALL THE FILES IN THE FOLDER
filtered = data.filter({ (text) -> Bool in let tmp: NSString = text as NSString let range = tmp.range(of: searchText, options: NSString.CompareOptions.caseInsensitive) return range.location != NSNotFound }) if(filtered.count == 0){ searchActive = false } else { searchActive = true } searchTableView.reloadData() // These next two lines dynamicaly adjust the Search TableView's height super.updateViewConstraints() self.searchTableViewHeightConstraint?.constant = self.searchTableView.contentSize.height }
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,876 PostsLatest Activity: 4 hours agoIf 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 or Facebook.
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!