If using the models, add django_s3
to INSTALLED_APPS
.
S3_HOST
: the hostname of the S3 endpointS3_ACCESS_KEY
: the access key IDS3_SECRET_KEY
: the secret access keyS3_BUCKETS
: adict
. Keys are abstract container names that can be passed toContainer.get()
. Values are the corresponding bucket names.
S3_STATICFILES_BUCKET
: the name of the bucket to be used by theS3StaticFileStorage
andS3CompressedFileStorage
classesS3_PORT
: the port number of the S3 endpointS3_SECURE_CONN
: whether to use TLS (default: True)S3_PUBLIC_HOST
: the hostname of a separate S3 endpoint to use in signed (public) URLsS3_PUBLIC_PORT
: the port number of the public S3 endpointS3_PUBLIC_SECURE_CONN
: whether to use TLS for the public endpoint (default: True)S3_SIGNED_URL_REFRESH_INTERVAL
: for signed URLs not provided for downloads (e.g. inline images), how often (in seconds) we should change the URL by default. Objects will be cachable for half this time on average. (default: 8 hours)S3_SIGNED_URL_GRACE
: how long (in seconds) a signed URL should be valid by default after we are no longer handing it out. This allows the user time to download the file. (default: 5 minutes)TEMPDIR
: a temporary directory formanage.py validatestorage
.
If you're only using the static file support, you don't need to add
django_s3
to INSTALLED_APPS
.
S3_STATICFILES_BUCKET = 'bucket-name'
STATIC_URL = 'https://storage.example.com/bucket-name/'
STATICFILES_STORAGE = 'django_s3.storage.S3StaticFileStorage'
S3_STATICFILES_BUCKET = 'bucket-name'
STATIC_URL = 'https://storage.example.com/bucket-name/'
STATIC_ROOT = '/path/to/local/sitestatic'
STATICFILES_STORAGE = 'django_s3.storage.S3CompressedFileStorage'
COMPRESS_STORAGE = 'django_s3.storage.S3CompressedFileStorage'