<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Get only files or only folders in a directory with Swiftydropbox in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Get-only-files-or-only-folders-in-a-directory-with-Swiftydropbox/m-p/205566#M9933</link>
    <description>&lt;P&gt;For example, this won't work, since the completion will be called too early:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;func getSubDirectory(path: String, completion: @escaping ([String]) -&amp;gt; ()) {
        var directories: [String] = []
        if let client = DropboxClientsManager.authorizedClient {
            client.files.listFolder(path: path).response { response, error in
                if let result = response {
                    print("Folder contents:")
                    for entry in result.entries {
                        client.files.getMetadata(path: (entry.pathLower)!).response { response, error in
                            if let metadata = response {
                                if let folder = metadata as? Files.FolderMetadata {
                                    print(folder.name)
                                    directories.append(folder.name)
                                }
                            }
                        }
                    }
                    completion(directories)
                } else {
                    print(error!)
                }
            }
        }
    }&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Feb 2017 02:48:31 GMT</pubDate>
    <dc:creator>Shades</dc:creator>
    <dc:date>2017-02-07T02:48:31Z</dc:date>
    <item>
      <title>Get only files or only folders in a directory with Swiftydropbox</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Get-only-files-or-only-folders-in-a-directory-with-Swiftydropbox/m-p/205565#M9932</link>
      <description>&lt;P&gt;How would I go about to get a list with only files or only folders in a directory. As far as I know, I can get the metadata with the client.files.getMetaData, but that seems like a backwards way of doing it by first getting all files and then getting all metadata. Especially if I have basically two closures in each other to set for example an array to use as a datasource for a tableview.&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:26:09 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Get-only-files-or-only-folders-in-a-directory-with-Swiftydropbox/m-p/205565#M9932</guid>
      <dc:creator>Shades</dc:creator>
      <dc:date>2019-05-29T09:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: Get only files or only folders in a directory with Swiftydropbox</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Get-only-files-or-only-folders-in-a-directory-with-Swiftydropbox/m-p/205566#M9933</link>
      <description>&lt;P&gt;For example, this won't work, since the completion will be called too early:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;func getSubDirectory(path: String, completion: @escaping ([String]) -&amp;gt; ()) {
        var directories: [String] = []
        if let client = DropboxClientsManager.authorizedClient {
            client.files.listFolder(path: path).response { response, error in
                if let result = response {
                    print("Folder contents:")
                    for entry in result.entries {
                        client.files.getMetadata(path: (entry.pathLower)!).response { response, error in
                            if let metadata = response {
                                if let folder = metadata as? Files.FolderMetadata {
                                    print(folder.name)
                                    directories.append(folder.name)
                                }
                            }
                        }
                    }
                    completion(directories)
                } else {
                    print(error!)
                }
            }
        }
    }&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 02:48:31 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Get-only-files-or-only-folders-in-a-directory-with-Swiftydropbox/m-p/205566#M9933</guid>
      <dc:creator>Shades</dc:creator>
      <dc:date>2017-02-07T02:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: Get only files or only folders in a directory with Swiftydropbox</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Get-only-files-or-only-folders-in-a-directory-with-Swiftydropbox/m-p/205639#M9939</link>
      <description>&lt;P&gt;You don't need to call getMetadata for each entry. You can perform the&amp;nbsp;as? Files.FolderMetadata or&amp;nbsp;Files.FileMetadata check on each Metadata object in the entries list returned by listFolder itself.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 16:22:09 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Get-only-files-or-only-folders-in-a-directory-with-Swiftydropbox/m-p/205639#M9939</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-02-07T16:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: Get only files or only folders in a directory with Swiftydropbox</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Get-only-files-or-only-folders-in-a-directory-with-Swiftydropbox/m-p/205642#M9942</link>
      <description>&lt;P&gt;I figured it out in the end, my solution ended up being like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;func getFolders(path: String, completion: @escaping ([String]) -&amp;gt; ()) {
        var directories: [String] = []
        if let client = DropboxClientsManager.authorizedClient {
            client.files.listFolder(path: path).response { response, error in
                if let result = response {
                    for entry in result.entries {
                        if let folder = entry as? Files.FolderMetadata {
                            directories.append(folder.name)
                        }
                    }
                    directories.sort { $0.capitalized &amp;lt; $1.capitalized }
                    completion(directories)
                } else {
                    print(error!)
                }
            }
        }
    }&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Feb 2017 16:26:28 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Get-only-files-or-only-folders-in-a-directory-with-Swiftydropbox/m-p/205642#M9942</guid>
      <dc:creator>Shades</dc:creator>
      <dc:date>2017-02-07T16:26:28Z</dc:date>
    </item>
  </channel>
</rss>

