Happy !

UdoSchneider / FileSystemNetwork

Project infos

License MIT
Tags filesystem, webdav, ftp
Creation date 2014-12-03
Website http://readthesourceluke.blogspot.de/2014/12/ftp-and-webdav-plugins-for-pharos.html

Monticello registration

About FileSystemNetwork

FTP and WebDAV Plugins for Pharo's FileSystem

Project info

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.

Project location

The project is located on STHub at http://smalltalkhub.com/#!/~UdoSchneider/FileSystemNetwork

Screenshot

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. Pharo FileList browser on mozilla.org FTP Server

Installation

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 (#webdav: and #ftp:) which return a Network filesystem. Both methods take a String or (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 #close the FileSystem instance. There might be dangling/open instances otherwise!

FTP

"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.

WebDAV

"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.

Packages

  • 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

Testing

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 FTPFileSystemTest reset.and WebdavFileSystemTest reset..

To Do

Enhanced FTP Server Support

Currently only FTP Servers running on *nix or Windows are supported. Support for NetWare and Rumpus are on the way.

S3 Support

Amazon S3 Support will be integrated soon as most of the functionality is already there due to the WebDAV/HTTP support.

License

The code is under MIT License.