Commit 6b9f346c by benjaoming

Merge pull request #92 from gluwa/master

Added custom storage backend to the images plugin
parents 64a22a81 55a4a5b2
......@@ -73,7 +73,10 @@ def upload_path(instance, filename):
import random, hashlib
m=hashlib.md5(str(random.randint(0,100000000000000)))
upload_path = path.join(upload_path, m.hexdigest())
return path.join(upload_path, filename + '.upload')
if settings.APPEND_EXTENSION:
filename += '.upload'
return path.join(upload_path, filename)
class AttachmentRevision(BaseRevisionMixin, models.Model):
......
......@@ -52,7 +52,8 @@ class ImageRevision(RevisionPluginRevision):
image = models.ImageField(upload_to=upload_path,
max_length=2000, height_field='height',
width_field='width', blank=True, null=True)
width_field='width', blank=True, null=True,
storage=settings.STORAGE_BACKEND)
width = models.SmallIntegerField(blank=True, null=True)
height = models.SmallIntegerField(blank=True, null=True)
......
......@@ -3,6 +3,9 @@ from django.conf import settings as django_settings
# Where to store images
IMAGE_PATH = getattr(django_settings, 'WIKI_IMAGE_PATH', "wiki/images/%aid/")
from django.core.files.storage import default_storage
STORAGE_BACKEND = getattr(django_settings, 'WIKI_STORAGE_BACKEND', default_storage)
# Should the upload path be obscurified? If so, a random hash will be added to the path
# such that someone can not guess the location of files (if you have
# restricted permissions and the files are still located within the web server's
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment