diff --git a/storages/backends/s3boto3.py b/storages/backends/s3boto3.py index 7231750f4..8e5ff2f00 100644 --- a/storages/backends/s3boto3.py +++ b/storages/backends/s3boto3.py @@ -561,6 +561,9 @@ def _strip_signing_parameters(self, url): joined_qs = ('='.join(keyval) for keyval in filtered_qs) split_url = split_url._replace(query='&'.join(joined_qs)) return split_url.geturl() + + def _get_expiration_for_cloudfront(self, expire): + return datetime.utcnow() + timedelta(seconds=expire) def url(self, name, parameters=None, expire=None, http_method=None): # Preserve the trailing slash after normalizing the path. @@ -578,7 +581,7 @@ def url(self, name, parameters=None, expire=None, http_method=None): ) if self.querystring_auth and self.cloudfront_signer: - expiration = datetime.utcnow() + timedelta(seconds=expire) + expiration = self._get_expiration_for_cloudfront(expire) return self.cloudfront_signer.generate_presigned_url(url, date_less_than=expiration) return url