I have multiple apps and each app has different cachecontrol requirement. get_object_parameters provides us. But it will be big change for codebase. Instead is it possible to pass cachecontrol to constructor e.g

S3Boto3Storage(**options = {
            'bucket_name': 'abc',
            'querystring_expire': 172800,
            'cachecontro': 'max-age=12000',
            'location': 'LINTING',
})

Right now its not working need to add this functionality in package.

1

There are 1 best solutions below

0
Omid Roshani On

You have to use a new Custom class that inherits S3Boto3Storage

from storages.backends.s3boto3 import S3Boto3Storage

class CustomS3Boto3Storage(S3Boto3Storage):
    def __init__(self, *args, **kwargs):
        cachecontrol = kwargs.pop('cachecontrol', None)
        super().__init__(*args, **kwargs)
        self.default_cache_control = cachecontrol

# Usage
storage = CustomS3Boto3Storage(
    bucket_name='abc',
    querystring_expire=172800,
    cachecontrol='max-age=12000',
    location='LINTING'
)