Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

23 lines (19 sloc) 0.679 kB
# encoding: utf-8
# Copyright 2011 Tree.io Limited
# This file is part of Treeio.
# License www.tree.io/license
"""
Custom storage for Documents to allow dynamic MEDIA_ROOT paths
"""
from django.core.files.storage import FileSystemStorage
from django.core.exceptions import SuspiciousOperation
from django.utils._os import safe_join
from treeio.core.conf import settings
import os
class FileStorage(FileSystemStorage):
def path(self, name):
try:
path = safe_join(getattr(settings, 'MEDIA_ROOT'), name)
except ValueError:
raise SuspiciousOperation("Attempted access to '%s' denied." % name)
return os.path.normpath(path)
Jump to Line
Something went wrong with that request. Please try again.