Hello,
I've trying to setup a web server inside my iOS app to serve a single video.m4v file (for now).
If I specify the local application bundle as the document root:
NSString *webPath = [[NSBundle mainBundle] resourcePath];
[self.httpServer setDocumentRoot:webPath];
and manually add the video.m4v file to the app bundle, it works.
However, when I try to use the iOS file system as the document root it doesn't
NSError* error = nil;
NSArray *repositoryParentFolder = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask];
NSArray *repositoryParentSubfoldersURL = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:[repositoryParentFolder objectAtIndex:0] includingPropertiesForKeys:nil options:0 error:&error];
for ( NSURL * obj in repositoryParentSubfoldersURL) {
if ( [[obj lastPathComponent] isEqualToString:@"videoRoot"]) {
NSURL *videoRoot = obj;
NSLog (@"found videoRoot: %@", videoRoot);
[self.httpServer setDocumentRoot:videoRoot.absoluteString];
break;
}
}
All I see from the server is:
HTTP/1.1 404 Not Found
Accept-Ranges: bytes
Content-Length: 0
I am at a loss why this is happening.
The docRoot gets printed out as :
file://localhost/Users/me/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/E1A845D9-0B00-4BB9-84FA-68F2955998B5/Documents/videoRoot/
it exists, and the video.m4v file is definitely there. Also when I query the running server for self.httpServer.documentRoot is responds with the same directory.
Anyone sees something here that I'm doing wrong ?
Thank you!
Rad