通过 NSURL 访问另一台电脑的文件

发布于 2024-10-21 08:15:22 字数 1002 浏览 3 评论 0原文

我可以通过 NSURL 访问我的本地文件:

    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"file://localhost/Users/user/Desktop/lucky_numbers.json"]];  

但我需要访问另一台电脑的文件。 我尝试过:

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"file://foyzulkarim:[email protected]/localhost/Users/foyzulkarim/Desktop/lucky_numbers.json"]];

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"file://192.168.1.48/localhost/Users/foyzulkarim/Desktop/lucky_numbers.json"]];

;

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"file://Foyzul-Karims-MacBook.local/localhost/Users/foyzulkarim/Desktop/lucky_numbers.json"]]

但错误显示 NSURLError 域代码 -1100

如果有人知道如何执行此操作,请帮助我。

I can access to my local file through NSURL by using:

    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"file://localhost/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:[email protected]/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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

謸气贵蔟 2024-10-28 08:15:22

我不那样工作。 file: URI 方案仅支持本地文件访问,不支持远程文件访问。对于远程访问,您需要一个真正的网络协议,例如 HTTP 或 FTP,以及远程站点上的服务器。

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.

断念 2024-10-28 08:15:22

您可以使用以下方法通过 NSURL 访问我的本地文件: NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"file://192.168.1.48/localhost/Volumes/foyzulkarim/Desktop/lucky_numbers.json"] ];

但是,要执行此操作,您必须首先手动连接该电脑。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文