Skip to content

AWS_S3_CUSTOM_DOMAIN usage #263

Open
@Mirrormsk

Description

Hi!

I'm using the plugin, and it works great. There are some differences after migrating from django-storages. I had to add the bucket prefix to AWS_S3_ENDPOINT_URL: https://<bucket_name>.old.s3.url instead of https://old.s3.url as it was before (this may be a peculiarity of my storage).

Also, I previously used AWS_S3_CUSTOM_DOMAIN with a public domain. To make everything work again, I had to override the form:

class VideoLessonAdminForm(forms.ModelForm):
    class Meta:
        model = VideoLesson
        fields = [
            "title",
            "description",
            "file",
            "poster",
            "lesson_page",
            "is_published",
        ]
        widgets = {
            "file": S3DirectWidget(dest="videos"),
        }

    def clean_file(self):
        value = self.cleaned_data.get("file")

        custom_domain = getattr(settings, "AWS_S3_CUSTOM_DOMAIN", None)
        aws_endpoint_url = getattr(settings, "AWS_S3_ENDPOINT_URL", None)

        if value and custom_domain and aws_endpoint_url:
            value = "https://" + value.replace(aws_endpoint_url, custom_domain)

        return value
        ```
Is there any way to use the AWS_S3_CUSTOM_DOMAIN variable in the plugin?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions