Open saileshkush95 opened 4 years ago
Sorry I'm little but busy, so I'm unable to follow this issue anyway thank you for your response. I'm already using django-storages and boto3. and here is my code snippets.
# AWS Configurations
AWS_ACCESS_KEY_ID = config('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = config('AWS_SECRET_ACCESS_KEY')
AWS_STORAGE_BUCKET_NAME = config('AWS_STORAGE_BUCKET_NAME')
AWS_DEFAULT_ACL = None
AWS_S3_OBJECT_PARAMETERS = {
'CacheControl': 'max-age=86400',
}
AWS_S3_FILE_OVERWRITE = False
from storages.backends.s3boto3 import S3Boto3Storage # noqa E402
AWS_S3_REGION_NAME = config('AWS_S3_REGION_NAME')
AWS_STORAGE_BUCKET_NAME = config('AWS_STORAGE_BUCKET_NAME')
class StaticRootS3Boto3Storage(S3Boto3Storage):
default_acl = 'public-read'
location = 'static'
custom_domain = f'{AWS_STORAGE_BUCKET_NAME}.s3.{AWS_S3_REGION_NAME}.amazonaws.com'
class MediaRootS3Boto3Storage(S3Boto3Storage):
file_overwrite = False
default_acl = 'public-read'
location = 'media'
custom_domain = f'{AWS_STORAGE_BUCKET_NAME}.s3.{AWS_S3_REGION_NAME}.amazonaws.com'
STATICFILES_STORAGE = 'config.settings.pro.StaticRootS3Boto3Storage'
STATIC_URL = f'https://{AWS_STORAGE_BUCKET_NAME}.s3.ap-south-1.amazonaws.com/ static/'
# # endregion
# DEFAULT_FILE_STORAGE = 'config.settings.pro.MediaRootS3Boto3Storage'
# MEDIA_URL = f'https://{AWS_STORAGE_BUCKET_NAME}.s3.ap-south-1.amazonaws.com/media/'
As for now I'm storing media files in my server, But i didn't want to do that. I want to store all of the media files upload by the user in the aws storage.
To make this work do i need to override this handle_uploaded_file
method
Yep. That's what I said. It comes down to making a new plugin with adjusted handle_uploaded_file
method.
So here, handling media files is not dependent on default django storage backend.?
I'm trying to store media files and static files in aws but it is now working for media files. Static files is working perfectly.