Reputation: 21
I am trying to browse and retrieve files from an HTTP server using the Commons VFS to implement the directory browsing functionality, find below my code snippet,
try {
StandardFileSystemManager manager = new StandardFileSystemManager();
manager.addProvider("http", new HttpFileProvider());
manager.setCacheStrategy(CacheStrategy.ON_CALL);
manager.setFilesCache(new SoftRefFilesCache());
FileObject fileObject = manager.resolveFile("http://localhost");
System.out.println(fileObject.getChildren());
} catch (FileSystemException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
But when i run this code i get the following exception,
org.apache.commons.vfs.FileSystemException: Could not list the contents of "http://localhost/" because it is not a folder.
at org.apache.commons.vfs.provider.AbstractFileObject.getChildren(AbstractFileObject.java:527)
at org.apache.commons.vfs.impl.DecoratedFileObject.getChildren(DecoratedFileObject.java:105)
at org.apache.commons.vfs.cache.OnCallRefreshFileObject.getChildren(OnCallRefreshFileObject.java:105)
at VFSClient.main(VFSClient.java:31)
But the server is up and running and am able to browse the directories.
Can anyone tell me what could be reason for this error, am I missing something ??
Upvotes: 2
Views: 2870
Reputation: 18310
Consider implementing a simple concrete repo on FS2. FS2 is a middleware api that handles all the CRUD, etc operations you need in a filesystem but can be backed by any persistence mechanism relatively easily.
Upvotes: 1
Reputation: 90150
Contrary to what the documentation says, I don't think this is implemented yet. Take a look at https://issues.apache.org/jira/browse/VFS-199
Upvotes: 0
Reputation: 81
HTTP seems not to support LIST_CHILDREN:
fileObject.getFileSystem().hasCapability(Capability.LIST_CHILDREN)
would return false
what version of VFS are you using? maybe v2.0 would help. The documentation says so: http://commons.apache.org/vfs/filesystems.html
Upvotes: 0