Skip to content

Instantly share code, notes, and snippets.

@abirafdirp
Last active October 9, 2018 08:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abirafdirp/abceb1efed936ab1c8db93e63a6ceed7 to your computer and use it in GitHub Desktop.
Save abirafdirp/abceb1efed936ab1c8db93e63a6ceed7 to your computer and use it in GitHub Desktop.
S3PrivateFileField
from django.db import models
class S3PrivateFileField(models.FileField):
"""
Using this for local storage is also viable since it's only an
instance attribute, which is not used in local storage.
"""
def __init__(self, verbose_name=None, name=None, upload_to='',
storage=None, **kwargs):
super().__init__(
verbose_name=verbose_name, name=name, upload_to=upload_to,
storage=storage, **kwargs
)
self.storage.default_acl = 'private'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment