Building42 / Telegraph

Secure Web Server for iOS, tvOS and macOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to serve directory from Documents Directory ?

leo2joseph opened this issue · comments

I am able to host the local server and load the files from Bundle using the code below,

let testBundleURL = URL(string: "Test", relativeTo:Bundle.main.resourceURL)!
server.serveDirectory(testBundleURL, "/test")

but when I try to serve the directory from the Documents directory, the page is blank. I don't see any error in the logs either. I have files stored in Documents directory.

let documentDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
server.serveDirectory(testBundleURL, "/test")

Can you tell how to serve from Application documents directory ?

Thanks for your help

Had some issues with starting the server, but now I am able to launch the server from Documents directory.

@leo2joseph Glad you figured it out! Sorry for my late reply, work has been crazy busy.