self.filebrowser_pre_upload.send(sender=request, path=request.POST.get('folder'), file=filedata)
            uploadedfile = handle_file_upload(path, filedata, site=self)
            
            if file_already_exists:
                old_file = smart_unicode(file_name)
                new_file = smart_unicode(uploadedfile)
                self.storage.move(new_file, old_file, allow_overwrite=True)
            
            self.filebrowser_post_upload.send(sender=request, path=request.POST.get('folder'), file=FileObject(smart_unicode(file_name), site=self))
            
            # let Ajax Upload know whether we saved it or not
            ret_json = {'success': True, 'filename': filedata.name}
            return HttpResponse(json.dumps(ret_json))

storage = DefaultStorage()
storage.location = MEDIA_ROOT
storage.base_url = MEDIA_URL
# Default FileBrowser site
site = FileBrowserSite(name='filebrowser', storage=storage)

# Default actions
from actions import *
site.add_action(flip_horizontal)
site.add_action(flip_vertical)
site.add_action(rotate_90_clockwise)
site.add_action(rotate_90_counterclockwise)
site.add_action(rotate_180)


예제 #2
0
        return func(request)

    return wrapper


def filebrowser_view_override(view):
    """ Add a strict decorator """
    return strict_decorator(never_cache(view))

# Monkey patch the view dispatcher
filebrowser.sites.filebrowser_view = filebrowser_view_override


class StrictFilebrowserSite(FileBrowserSite):
    """Is there just so the app works"""
    pass


storage = DefaultStorage()
storage.location = settings.MEDIA_ROOT
storage.base_url = settings.MEDIA_URL
# Default FileBrowser site
site = StrictFilebrowserSite(name='filebrowser', storage=storage)

# Default actions
site.add_action(flip_horizontal)
site.add_action(flip_vertical)
site.add_action(rotate_90_clockwise)
site.add_action(rotate_90_counterclockwise)
site.add_action(rotate_180)
예제 #3
0
                                                     site=self)
                thumbnail_path = self.storage.url(version_path)
            else:
                thumbnail_path = ''

            # let Ajax Upload know whether we saved it or not
            ret_json = {
                'success': True,
                'filename': filedata.name,
                'path': fobj.path,
                'url': fobj.url,
                'thumbnail': thumbnail_path,
                'filetype': fobj.filetype
            }
            return HttpResponse(json.dumps(ret_json))


storage = DefaultStorage()
storage.location = MEDIA_ROOT
storage.base_url = MEDIA_URL
# Default FileBrowser site
site = FileBrowserSite(name='filebrowser', storage=storage)

# Default actions
from actions import *
site.add_action(flip_horizontal)
site.add_action(flip_vertical)
site.add_action(rotate_90_clockwise)
site.add_action(rotate_90_counterclockwise)
site.add_action(rotate_180)
예제 #4
0
from tempfile import NamedTemporaryFile

# Django imports
from django.conf import settings
from django.core.files.storage import DefaultStorage
from django.core.files import File

# PIL import
try:
    from PIL import Image
except ImportError:
    import Image

storage = DefaultStorage()
storage.location = settings.MEDIA_ROOT
storage.base_url = settings.MEDIA_URL


def path_strip(path, root):
    if not path or not root:
        return path
    path = os.path.normcase(path)
    root = os.path.normcase(root)
    if path.startswith(root):
        return path[len(root) :]
    return path


def get_version_path(value, version_prefix, root):
    """
    Construct the PATH to an Image version.