The “FileSystemNetwork” project is a small library which adds WebDAV and FTP support to Pharo’s FileSystem framework. This allows you to use remote WebDAV and FTP locations with the same (FileSystem) API that’s used for disk access.
The project is located on STHub at http://smalltalkhub.com/#!/~UdoSchneider/FileSystemNetwork
Because the Pharo Tools use FileSystem as their underlying framework even those built-in tools are now able to use remote WebDAV and FTP locations.
To install everything (WebDAV, FTP and tests) simply use:
Gofer it smalltalkhubUser: 'UdoSchneider' project: 'FileSystemNetwork'; configuration; loadStable.
If you don’t want to load everything the configuration provides (two) three groups:
Webdav: (Only WebDav - no tests)
FTP: (Only FTP - no tests)
Tests: (All tests - loads everything)
E.g. to only load WebDAV support use
Gofer it smalltalkhubUser: 'UdoSchneider' project: 'FileSystemNetwork'; configuration; load. #ConfigurationOfFileSystemNetwork asClass project stableVersion load: 'Webdav'
Use in your own application
Once loaded the
FileSystem class provides additional methods (
#ftp:) which return a Network filesystem. Both methods take a
(Zn)Url argument which allows you to specify username, password, host, port and initial working directory (e.g.
[scheme]://[username]:[password]@[hostname]:[port][workingdirectory]. Once you obtained the
FileSystem you can use the usual
FileSystem API (see Files with FileSystem for examples).
NOTE: Please remember to always
FileSysteminstance. There might be dangling/open instances otherwise!
"Obtain a FTP FileSystem" fs := FileSystem ftp: 'ftp://ftp.mozilla.org'. "Get working directory" wd := fs workingDirectory . "Print the following expression!" (wd / 'pub' / 'firefox') children. "Open a FileList on the FileSystem" FileList openOn: wd. "Remember to close if you are finished!" fs close.
"Obtain a WebDAV FileSystem" fs := FileSystem webdav: 'https://udoschneider:PASSWORD@webdav.hidrive.strato.com/users/udoschneider/'. "Get working directory" wd := fs workingDirectory. "Open a FileList on the FileSystem" FileList openOn: wd. "Remember to close if you are finished!" fs close.
FileSystem-Network-Core- package with core/protocol independent functionality
FileSystem-Tests-Network-Core- package with core tests
FileSystem-Network-FTP- package with FTP functionality
FileSystem-Tests-Network-FTP- package with FTP tests
FileSystem-Network-Webdav- package with WebDAV functionality
FileSystem-Tests-Network-Webdav- package with WebDAV tests
The package comes with 156 tests in the test packages (most of them inherited from
FileSystem tests). All tests are green on the clients/servers I used.
NOTE If you want to verify that a certain server works correctly simply run the tests against this server. Please remember that you need write access for the tests to be successful.
NOTE The server URLs for WebDAV and FTP are not hardcoded in the tests. You will be requested to provide FTP and WebDAV URLs on first run. If you want to reset the cached URLs use
Enhanced FTP Server Support
Currently only FTP Servers running on *nix or Windows are supported. Support for NetWare and Rumpus are on the way.
Amazon S3 Support will be integrated soon as most of the functionality is already there due to the WebDAV/HTTP support.
The code is under MIT License.