Dropbox API Listing a folder Listing the root folder using the SwiftyDropbox library, distinguishing files and folders in the response

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Dropbox.authorizedClient!.files.listFolder(path: "").response { response, error in
    print("*** List folder ***")
    if let result = response {
        print("Folder contents:")
        for entry in result.entries {
            print(entry.name)
            if let file = entry as? Files.FileMetadata {
                print("\tThis is a file with path: \(file.pathLower) and size: \(file.size)")
            } else if let folder = entry as? Files.FolderMetadata {
                print("\tThis is a folder with path: \(folder.pathLower)")
            }
        }
    } else if let callError = error {
        switch callError {
        case .RouteError(let boxed, _):
            switch boxed.unboxed {
            case .Path(let lookupError):
                print("lookupError:")
                print(lookupError)
            case .Other:
                print("Other")
            }
        default:
            print("default")
        }
    }
}

Note that the response may contain ListFolderResult.hasMore=true, in which case your app should call back using listFolderContinue to continue getting more entries.



Got any Dropbox API Question?