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 S3 bucket.
  • S3Boto3Storage is used to store media files in Amazon S3 bucket.
  • AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are used to authenticate with Amazon S3.
  • AWS_STORAGE_BUCKET_NAME is used to specify the Amazon S3 bucket name.
  • INSTALLED_APPS is used to install the storages app.
  • Category Static & Media Files
  • Total Views 715
  • Last Modified 29 April, 2026
  • Tags #media #s3 #storage #deployment
Never miss a story on Django.wiki

Subscribe for fresh tutorials, snippets, and updates.

By subscribing you agree to our Privacy Policy.