【问题标题】:Navigate to the root directory via FTP URI with Apache Commons VFS使用 Apache Commons VFS 通过 FTP URI 导航到根目录
【发布时间】:2012-11-21 13:34:48
【问题描述】:

我不知道如何从根目录引用文件。目前,URI 中的任何路径都是用户目录的子目录。我正在尝试通过以下方式访问 /var/www:

sftp://user:password@host/var/www

但它是无效的。

org.apache.commons.vfs2.FileNotFolderException: Could not list the contents of "sftp://user:***@host/var/www" because it is not a folder.

【问题讨论】:

    标签: java apache-commons jsch apache-commons-vfs


    【解决方案1】:

    我找到了解决办法。

    SftpFileSystemConfigBuilder builder = SftpFileSystemConfigBuilder.getInstance();
    FileSystemOptions options = new FileSystemOptions();
    builder.getKnownHosts(options);
    builder.setUserDirIsRoot(options, false);
    builder.setTimeout(options, 5000);
    
    FileObject directory = manager.resolveFile("sftp://user:password@host/var/www", options);
    

    【讨论】:

    • 工作就像一个魅力!非常感谢
    猜你喜欢
    • 2012-05-04
    • 1970-01-01
    • 1970-01-01
    • 2012-04-02
    • 1970-01-01
    • 2013-05-30
    • 1970-01-01
    • 2017-01-19
    • 1970-01-01
    相关资源
    最近更新 更多