Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom storage support #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions filebrowser/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from django.utils.translation import ugettext as _
from django.utils.safestring import mark_safe
from django.core.files import File
from django.core.files.storage import default_storage
from django.utils.encoding import smart_str

# filebrowser imports
Expand Down Expand Up @@ -238,7 +237,7 @@ def handle_file_upload(path, file):
"""

file_path = os.path.join(path, file.name)
uploadedfile = default_storage.save(file_path, file)
uploadedfile = FILEBROWSER_STORAGE.save(file_path, file)
return uploadedfile


Expand Down
14 changes: 14 additions & 0 deletions filebrowser/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@
DEFAULT_URL_TINYMCE = settings.ADMIN_MEDIA_PREFIX + "tinymce/jscripts/tiny_mce/"
DEFAULT_PATH_TINYMCE = os.path.join(settings.MEDIA_ROOT, 'admin/tinymce/jscripts/tiny_mce/')

# storage settings
if hasattr(settings, 'FILEBROWSER_STORAGE_CLASS'):
from django.core.files.storage import get_storage_class
from django.utils.functional import LazyObject

class FilebrowserStorageClass(LazyObject):
def _setup(self):
self._wrapped = get_storage_class(import_path=settings.FILEBROWSER_STORAGE_CLASS)()

FILEBROWSER_STORAGE = FilebrowserStorageClass()
else:
from django.core.files.storage import default_storage
FILEBROWSER_STORAGE = default_storage

# Set to True in order to see the FileObject when Browsing.
DEBUG = getattr(settings, "FILEBROWSER_DEBUG", False)

Expand Down