You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

dahunter's avatar
dahunter
New member | Level 2
5 years ago

how to extract name and pathdisplay from swiftydropbox searchv2 results

I have an app in which I was using the SwiftyDropbox function  client.files.search   and now I'm upgrading to the new client.files.searchV2   However, the results have also changed structure (t...
  • Greg-DB's avatar
    5 years ago

    With the new method, you can access the metadata like this:

    client.files.searchV2(query: query).response { response, error in
        if let response = response {
            for entry in response.matches {
                switch entry.metadata {
                case .metadata(let metadata):
                    switch metadata {
                        case let fileMetadata as Files.FileMetadata:
                            print("File name: \(fileMetadata.name)")
                            print("File display path: \(fileMetadata.pathDisplay ?? "")")
                        case let folderMetadata as Files.FolderMetadata:
                            print("Folder name: \(folderMetadata.name)")
                            print("Folder display path: \(folderMetadata.pathDisplay ?? "")")
                        case let deletedMetadata as Files.DeletedMetadata:
                            print("Deleted entry name: \(deletedMetadata.name)")
                    default:
                        print("unknown metadata type")
                    }
                default:
                    print("unknown entry type")
                }
            print("")
            }
        } else if let error = error {
            print(error)
        }
    }

About Discuss Dropbox Developer & API

Node avatar for Discuss Dropbox Developer & API

Make connections with other developers

797 PostsLatest Activity: 2 days ago
199 Following

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 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!