Amazon S3 Storage for Media Files
A snippet showing how to store media files in Amazon S3.
# settings.py
INSTALLED_APPS += ['storages']
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
AWS_ACCESS_KEY_ID = 'your-access-key'
AWS_SECRET_ACCESS_KEY = 'your-secret-key'
AWS_STORAGE_BUCKET_NAME = 'your-bucket-name'
Explanation:
-
Uploaded media files are stored in
Amazon S3bucket. -
S3Boto3Storageis used to store media files in Amazon S3 bucket. -
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEYare used to authenticate with Amazon S3. -
AWS_STORAGE_BUCKET_NAMEis used to specify the Amazon S3 bucket name. -
INSTALLED_APPSis used to install thestoragesapp.
- Category Static & Media Files
- Total Views 715
- Last Modified 29 April, 2026
- Tags #media #s3 #storage #deployment
Previous snippet
Collect Static Files with collectstatic
Next snippet