DEV Community

Cover image for How to write an Extensible File Manager
Mehran Davoudi
Mehran Davoudi

Posted on

How to write an Extensible File Manager

You have probably worked with lots of file managers on different platforms. Android, macOS, Windows... each of these platforms has their own specific file manager. What if we could have a file manager for all? Not limited to these file systems, but extensible to support any further file system in the future.

This is what we have started to develop in Functionland: an open-source file manager open for extensibility.

As we investigated the requirements to extend a file manager, we reached out to these extension slots:

  • Adding new File Providers
  • Adding Thumbnail support for new file types
  • Adding File Viewer for new file types

In this post, I'm going to talk only about the first extensibility slot: File Providers.

But before seeing how such architecture is possible, I encourage you to see this video which demonstrates the result of our work, Fx Files with its elegant UI:

Watch Fx Files

Adding new File Providers

A well-designed file manager should have the potential to support more and more new file providers. Now we support for Windows, Android, and macOS; but these are not the only file providers in the world.

Not only offline file providers, but also developers should be able to add any online file providers like:

  • FTP
  • IPFS
  • AWS S3
  • Azure Storage
  • Google Drive
  • Microsoft OneDrive
  • TON Storage
  • or any other online file provider...

To support all these types should have a special architecture in our file manager.

Fx Files UI components are designed in way that they can work with any file provider that implements IFileService interface. This interface provides whatever we expect from a file provider, and to add support for a new provider you need just add a new class implementing this interface:

public class AzureStorageFileService : IFileService
{
    // The implementation for Azure Blob Storage 
    // This implementation specifies how to work with files on Azure
    // like copying, moving, deleting, searching and ...
}
Enter fullscreen mode Exit fullscreen mode

And as this class is IFileService the UI knows how to explore this file provider and do actions like copy, move and ... on its files.

File Service Hierarchy

In this way, community developers can easily add support for new types of file providers like FTP, and work with them just like their other files.

The foundation of this app has been developed now and is available here on GitHub:

For adding new FileService you can find a more comprehensive technical document here.

Finally, it is good to know that this great architecture has been designed as a part of a Blockchain Attached Storage (BAS) project by Functionland! So in future the Functionland dev team can easily add support for their blockchain file api (called Fula) to the app.

Top comments (0)