⬆️(backend) upgrade boto3 to 1.14.4 for unsigned urls
For media urls, we want to compute authorization as a header instead of computing signed urls. The url of a media file can then be computed without the querystring authorization part. This requires upgrading django-storages to the 1.14 version to benefit from the "unsigned connection" in the S3Storage backend.
This commit is contained in:
committed by
Samuel Paccoud
parent
58eaea000c
commit
f12708acee
@@ -324,16 +324,23 @@ class Document(BaseModel):
|
|||||||
file_key = self.file_key
|
file_key = self.file_key
|
||||||
bytes_content = self._content.encode("utf-8")
|
bytes_content = self._content.encode("utf-8")
|
||||||
|
|
||||||
if default_storage.exists(file_key):
|
# Attempt to directly check if the object exists using the storage client.
|
||||||
|
try:
|
||||||
response = default_storage.connection.meta.client.head_object(
|
response = default_storage.connection.meta.client.head_object(
|
||||||
Bucket=default_storage.bucket_name, Key=file_key
|
Bucket=default_storage.bucket_name, Key=file_key
|
||||||
)
|
)
|
||||||
|
except ClientError as excpt:
|
||||||
|
# If the error is a 404, the object doesn't exist, so we should create it.
|
||||||
|
if excpt.response["Error"]["Code"] == "404":
|
||||||
|
has_changed = True
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
# Compare the existing ETag with the MD5 hash of the new content.
|
||||||
has_changed = (
|
has_changed = (
|
||||||
response["ETag"].strip('"')
|
response["ETag"].strip('"')
|
||||||
!= hashlib.md5(bytes_content).hexdigest() # noqa
|
!= hashlib.md5(bytes_content).hexdigest() # noqa: S324
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
has_changed = True
|
|
||||||
|
|
||||||
if has_changed:
|
if has_changed:
|
||||||
content_file = ContentFile(bytes_content)
|
content_file = ContentFile(bytes_content)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ dependencies = [
|
|||||||
"django-parler==2.3",
|
"django-parler==2.3",
|
||||||
"redis==5.0.8",
|
"redis==5.0.8",
|
||||||
"django-redis==5.4.0",
|
"django-redis==5.4.0",
|
||||||
"django-storages[s3]==1.14.2",
|
"django-storages[s3]==1.14.4",
|
||||||
"django-timezone-field>=5.1",
|
"django-timezone-field>=5.1",
|
||||||
"django==5.0.8",
|
"django==5.0.8",
|
||||||
"djangorestframework==3.15.2",
|
"djangorestframework==3.15.2",
|
||||||
|
|||||||
Reference in New Issue
Block a user