Alec.
Alec.

Reputation: 5525

Populate tableview with online file directory

I have the following code

 let webPath =  URL(string: "http://peterlinnik.com/Plex%20Music/The%20Beatles%20-%20Discography/Abbey%20Road/")

        do {
            // Get the directory contents urls (including subfolders urls)
            let webFiles = try FileManager.default.contentsOfDirectory(at: webPath!, includingPropertiesForKeys: nil, options: [])
            print(webFiles)


        } catch let error as NSError {
            print(error.localizedDescription)
        }

I am trying to populate a tableview with the contents of this directory, at the moment I'm just trying to get it to print what's there but receive the following error,

The folder “Abbey Road” doesn’t exist.

What am I doing wrong, can this even be done?

enter image description here

Upvotes: 2

Views: 96

Answers (1)

Eric Aya
Eric Aya

Reputation: 70096

A web URL is not a file URL.

Your URL points to an HTML page - this has nothing to do with filesystem folders.

The server's folders that you see displayed via HTML are not exposed directly to you as actual folders.

Upvotes: 1

Related Questions