get access to a file of another PC through NSURL
I can access to my local file through NSURL by using:
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"file://l开发者_JAVA百科ocalhost/Users/user/Desktop/lucky_numbers.json"]];
But I need to get access of a file of another PC. I tried:
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"file://foyzulkarim:000000@192.168.1.48/localhost/Users/foyzulkarim/Desktop/lucky_numbers.json"]];
and
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"file://192.168.1.48/localhost/Users/foyzulkarim/Desktop/lucky_numbers.json"]];
and
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"file://Foyzul-Karims-MacBook.local/localhost/Users/foyzulkarim/Desktop/lucky_numbers.json"]];
But Error shows NSURLError domain code -1100
Please help me if anyone knows how to do this.
I doesn't work that way. The file:
URI scheme only supports local file access, not remote. For remote access you need a real network protocol like HTTP or FTP and thus a server on the remote site.
You can access to my local file through NSURL by using: NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"file://192.168.1.48/localhost/Volumes/foyzulkarim/Desktop/lucky_numbers.json"]];
but, to do this you have to first connect with that PC manually.
精彩评论