New in version 3.4.0.
Starting with FileBrowser 3.4, you have the option to specify which file storage engine a FileBrowser should use to browse/upload/modify your media files. This enables you to use a FileBrowser even if your media files are located at some remote system.
To associate a FileBrowser site with a particular storage, set the storage property of a site object:
from django.core.files.storage import FileSystemStorage
site.storage = FileSystemStorage(location='/path/to/media/directory', base_url='/media/')
For storage classes other than FileSystemStorage (or those that inherit from that class), there’s a little bit more effort involved in providing a storage object that can be used with FileBrowser. See StorageMixin Class
Note
Prior FileBrowser 3.4, the way to specify FileBrowser‘s MEDIA_ROOT and MEDIA_URL was via settings.py. Starting from version 3.4, those variables are associated with the storage instance and you can set them as illustrated in the above example.
A FileBrowser uses the Django’s Storage class to access media files. However, the API of the Storage class does not provide all methods necessary for FileBrowser’s functionality. A StorageMixin class from filebrowser.storage module therefore defines all the additional methods that a FileBrowser requires:
Returns true if name exists and is a directory.
Returns true if name exists and is a regular file.
Creates all missing directories specified by name. Analogue to os.mkdirs().
Deletes a directory and everything it contains. Analogue to shutil.rmtree().
Note
FileBrowser provides these methods only for FileSystemStorage (by mixing-in the filebrowser.storage.FileSystemStorageMixin class). If you’re using a custom storage engine, which does not inherit from Django’s FileSystemStorage, you will need to provide those method yourself.