diff --git a/README.rst b/README.rst index 7327090..b7679e9 100644 --- a/README.rst +++ b/README.rst @@ -32,13 +32,15 @@ Settings 'bucket': None, 'project': '', 'credentials': None, - 'http': None + 'http': None, + 'cache_control': ['no-cache'] } * ``bucket`` name of the bucket on google cloud storage. * ``project`` google project name (not required). * ``credentials`` oauth2 credentials * ``http`` httplib2.Http instance or callable that returns httplib2.Http instance +* ``cache_control`` is a list of strings. By default ['no-cache'] *Note: One of* ``credentials`` *or* ``http`` *should be provided for authentication.* diff --git a/django_gcs/settings.py b/django_gcs/settings.py index 8790c6c..470238d 100644 --- a/django_gcs/settings.py +++ b/django_gcs/settings.py @@ -5,7 +5,8 @@ 'bucket': None, 'project': '', 'credentials': None, - 'http': None + 'http': None, + 'cache_control': ['no-cache'] } diff --git a/django_gcs/storage.py b/django_gcs/storage.py index bbceaab..6e6d265 100644 --- a/django_gcs/storage.py +++ b/django_gcs/storage.py @@ -51,8 +51,11 @@ def _save(self, name, content): content_type = content.content_type else: content_type = mimetypes.guess_type(name)[0] - blob.cache_control = settings.GOOGLE_CLOUD_STORAGE.get('cache_control') blob.upload_from_file(content, True, content.size, content_type) + + blob.cache_control = ', '.join(settings['cache_control']) + blob.patch() # submit cache_control + blob.make_public() return name