Open Aramgutang opened 5 years ago
Just wanted to note, since it was hard to track down, a reference of the allowed object parameters can be found here: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Object.initiate_multipart_upload
@Aramgutang Thanks, this was recently brought to my attention again and I finally got around to looking at it. You are indeed correct, the order of the mixins is reversed. Just switching them so S3GetContentHashMixin
is before UniqueMixin
should be all that is needed.
You are probably also correct about the expiry settings. However we are now using R2 instead of S3 and I don't think it supports the per object expiry, and we handle this in our Cloudflare worker which provides public and private access to the R2 bucket.
But your suggestion does seem reasonable for S3 buckets.
There are numerous issues with the way storages are set up in ixc-django-docker.
For starters, this: https://github.com/ixc/ixc-django-docker/blob/bcf550f463c45ed3e6fef265d9f7d04a77566974/ixc_django_docker/settings/storages.py#L4-L7
Per the current django-storages docs, that actually has no effect, since it's only used with boto, not boto3, and we use the latter.
The suggested way to define a never-expire cache instead is via object parameters (also note the use of a properly large
max-age
):However, I would hesitate to use that, as it would be the default for all uploads, not just those that use unique filenames, and we probably only want to use it when using unique filename storage. It would probably be best to add a new mixin:
And then add that to the list of mixins when constructing the unique storages: https://github.com/ixc/ixc-django-docker/blob/bcf550f463c45ed3e6fef265d9f7d04a77566974/ixc_django_docker/storage.py#L137-L152
Speaking of the list of mixins above, note
UniqueMixin
followed byS3GetContentHashMixin
. The only functionality the latter provides is an overriddenget_content_hash()
method. However,UniqueMixin
also overridesget_content_hash()
, and doesn't callsuper()
within it, so the functionality ofS3GetContentHashMixin
is never invoked. I'm not sure what the history of that mixin is and what it's trying to accomplish, so I don't have any specific suggestions other than for someone with more contextual knowledge to review the situation and either make its functionality invokable, or remove it altogether.