Skip to content

Instantly share code, notes, and snippets.

@benzkji
Last active August 29, 2015 14:23
Show Gist options
  • Save benzkji/5f14fef05021f325c7ef to your computer and use it in GitHub Desktop.
Save benzkji/5f14fef05021f325c7ef to your computer and use it in GitHub Desktop.
django-filer no subfolders
import os
from filer.utils.files import get_valid_filename
def no_subfolders(instance, filename):
return get_valid_filename(filename)
FILER_STORAGES = {
'public': {
'main': {
'ENGINE': 'filer.storage.PublicFileSystemStorage',
'OPTIONS': {
'location': os.path.join(MEDIA_ROOT, 'filer'),
'base_url': '%sfiler/' % MEDIA_URL,
},
'UPLOAD_TO': 'project.filer_upload_to.no_subfolders',
'UPLOAD_TO_PREFIX': '',
},
'thumbnails': {
'ENGINE': 'filer.storage.PublicFileSystemStorage',
'OPTIONS': {
'location': os.path.join(MEDIA_ROOT, 'thumbs'),
'base_url': '%sthumbs/' % MEDIA_URL,
},
},
},
'private': {
'main': {
'ENGINE': 'filer.storage.PrivateFileSystemStorage',
'OPTIONS': {
'location': os.path.join(MEDIA_ROOT, 'filer_private'),
'base_url': '%sfiler' % MEDIA_URL,
},
'UPLOAD_TO': 'project.filer_upload_to.no_subfolders',
'UPLOAD_TO_PREFIX': '',
},
'thumbnails': {
'ENGINE': 'filer.storage.PrivateFileSystemStorage',
'OPTIONS': {
'location': os.path.join(MEDIA_ROOT, 'private_thumbs'),
'base_url': '%sprivate_thumbs/' % MEDIA_URL,
},
},
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment