简体   繁体   English

FTP的虚拟文件系统

[英]Virtual File System with FTP

I've been reading through the FileSystem documentation in Python from here: http://packages.python.org/fs/filesystems.html 我从这里开始阅读Python中的FileSystem文档: http//packages.python.org/fs/filesystems.html

After taking the time to read through it and a bit of Google-ing I didn't quite find the answer I was looking for. 在花时间阅读它和一些Google-ing后,我找不到我想要的答案。 I was wondering if it was possible with Python, and avoiding any UAC issues on Windows, if you could 'mount' or display a file free from an FTP server inside Windows Explorer for any other applications to -read- from. 我想知道是否有可能使用Python,并避免在Windows上出现任何UAC问题,如果你可以在Windows资源管理器中“挂载”或显示一个免费的FTP服务器文件,那么任何其他应用程序都可以从中读取。

Is something this possible? 这有可能吗? What's the best approach to achieve it? 实现它的最佳方法是什么? Thanks in advance! 提前致谢!

Windows explorer has built-in support for FTP, instructions with screenshots here . Windows资源管理器内置了对FTP的支持, 这里有截图说明

  1. Open Windows Explorer (My computer) 打开Windows资源管理器(我的电脑)
  2. Right-click anywhere in the folder, and then click Add a Network Location. 右键单击文件夹中的任意位置,然后单击“添加网络位置”。
  3. This displays the Add Network Connection wizard. 这将显示“添加网络连接”向导。 Click Next. 点击下一步。
  4. In the wizard, select Choose a custom network location, and then click Next. 在向导中,选择“选择自定义网络位置”,然后单击“下一步”。
  5. Enter the name of the FTP site, with the full FTP:// in front of it, and then click Next (something like - for example if you domain name is DOMAIN.NET the full name should look like this: ). 输入FTP站点的名称,前面有完整的FTP://,然后单击Next(类似于 - 例如,如果您的域名是DOMAIN.NET,则全名应如下所示:)。
  6. To use a name and password, clear the Log on anonymously check box. 要使用名称和密码,请清除“匿名登录”复选框。 Type your FTP Account Username, and then click Next. 键入您的FTP帐户用户名,然后单击“下一步”。
  7. By default, the name of the shortcut is the same as the FTP address. 默认情况下,快捷方式的名称与FTP地址相同。 If you want to give the shortcut a different name, type it in the Type a name for this network location box. 如果要为快捷方式指定其他名称,请在“键入此网络位置的名称”框中键入该名称。 Click Next. 点击下一步。

You can even use it from the standard "file" dialog box. 您甚至可以从标准的“文件”对话框中使用它。 Is it enough? 够了吗?

[update] [更新]

Out of curiosity, does this have support for FTPS and/or SFTP? 出于好奇,这是否支持FTPS和/或SFTP? – André Caron - 安德烈卡隆

@AndréCaron: I think WebDAV with SSL is supported, but no native support for SFTP or FTPS. @AndréCaron:我认为支持使用SSL的WebDAV,但不支持SFTP或FTPS。 There are extensions like Swish (opensource) or Expandrive (payware). Swish (开源)或Expandrive (付费软件)等扩展。

This is a non-trivial matter and afaik there exist not such a thing as provide os-level functionality through some lines of magical python code. 这是一个非常重要的事情,并且不存在通过某些神奇的python代码提供os级功能的事情。

A possible solution to emulate your intention could be to create a local webdav proxy, which maps to the ftp-server. 模拟您的意图的可能解决方案可能是创建一个映射到ftp-server的本地webdav代理。 I know there exists a feature to attach a webdav-network device to a local drive-letter, but because the last time i touched a windows system was ... - i can't even remember - i can't tell you if you might also attach a ftp-resource this way directly. 我知道有一个功能将webdav网络设备连接到本地驱动器号,但因为我上次触摸Windows系统是... - 我甚至不记得 - 我不能告诉你,如果你也可以直接以这种方式附加ftp资源。

I guess looking for a solution on a python level might not be productive in a short-term perspective and even on mid/long-term's not possible without heavy tinkering on your side. 我想在python级别上寻找一个解决方案在短期内可能效率不高,即使在中期/长期也不可能没有大量的修补。

While not a "filesystem" per-se, you can provide a Windows Explorer Namespace Extension which will allow the Windows explorer to browse any virtual file-system. 虽然不是“文件系统”本身,但您可以提供Windows资源管理器命名空间扩展 ,它允许Windows资源管理器浏览任何虚拟文件系统。 This is used to implement browsing of ZIP archives, for example. 例如,这用于实现ZIP存档的浏览。 Note that this does not provide a real file system drive, so it will not allow you to open the contents of this namespace extension using regular file I/O functions. 请注意,这不提供真正的文件系统驱动器,因此它不允许您使用常规文件I / O函数打开此命名空间扩展的内容。

The namespace extensions are written in COM, and it is possible to implement COM interfaces in Python . 命名空间扩展是用COM编写的,可以在Python中实现COM接口

AFAIK, the only permissions you need are for installing of the namespace extension (the COM DLL, plus the namespace registration). AFAIK,您需要的唯一权限是安装命名空间扩展(COM DLL,以及命名空间注册)。 Everything else runs in the logged-in user's context and requires no special permissions. 其他所有内容都在登录用户的上下文中运行,不需要特殊权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM