Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

Commit

Permalink
attachment dir configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Amin Dandache committed Jun 14, 2017
1 parent 773e7d8 commit 514fdb5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,7 @@ against various storages such as S3 Boto.
To force Django's File System storage::

MAILQUEUE_STORAGE = True

To change the Attachment dir::

MAILQUEUE_ATTACHMENT_DIR = 'mailqueue-attachments'
4 changes: 3 additions & 1 deletion mailqueue/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from django.core.files.storage import FileSystemStorage
from django.utils.crypto import get_random_string

MAILQUEUE_ATTACHMENT_DIR = getattr(settings, 'MAILQUEUE_ATTACHMENT_DIR', 'mailqueue-attachments')


class MailerStorage(FileSystemStorage):
def __init__(self, location=None):
Expand All @@ -27,4 +29,4 @@ def upload_to(instance, filename):
filename = filename.split('/')[-1]
# Because instead of filesystem, email message
# can have multiple attachments with the same filename
return 'mailqueue-attachments/{0}_{1}'.format(get_random_string(length=24), filename)
return '{0}/{1}_{2}'.format(MAILQUEUE_ATTACHMENT_DIR, get_random_string(length=24), filename)

0 comments on commit 514fdb5

Please sign in to comment.