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. See also the Django’s documentation on storages https://docs.djangoproject.com/en/dev/topics/files/.
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
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.
For the reason of backward compatibility, FileBrowser settings FILEBROWSER_MEDIA_ROOT and FILEBROWSER_MEDIA_URL can still be used to customize FileBrowser as long as you’re using the default FileBrowser‘s site without having changed its storage engine. In the next major release of FileBrowser these settings will be removed.
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().
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.