Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs for multiple buckets with varying properties, Digital Ocean signed URLs with CDN domain #1075

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

awhileback
Copy link

@awhileback awhileback commented Oct 15, 2021

from guide posted in #944, also referenced in #395

I double checked and cleaned up the example template filter, but I don't use DO Spaces and would rather not pay 5 bucks to test this if possible, perhaps @lifenautjoe can verify that this all works on his DO account.

@paulkuhle
Copy link

paulkuhle commented Apr 8, 2022

I followed the steps in the updated docs and can verify that they work perfectly.

One minor thing: I had to also add the storage bucket name to the replace function, given that django-storages generates the link in this format (https://fra1.digitaloceanspaces.com/example-cdn instead of https://example-cdn.fra1.digitaloceanspaces.com).

This is a quick example of how this would look like in a graphene resolver (I imagine the same principle applies to template filters, DRF endpoints, etc. - maybe it would be a good idea to make this section more generic in the docs?):

def resolve_file(parent, info):
    url = parent.file.url
    if settings.AWS_S3_ENDPOINT_URL in url:
        cdn_domain = 'https://cdn.example.com'
        new_url = url.replace(
            f"{settings.AWS_S3_ENDPOINT_URL}/{settings.AWS_STORAGE_BUCKET_NAME}", cdn_domain)
        return new_url
    return url

It would be great if we could get this merged soon given that it's really valuable information. 👍

@jambonrose
Copy link

Thank you for writing these docs.

Unfortunately, the Digital Ocean docs now has a section that states:

Using presigned URLs does not allow transferred files to be cached when using the Spaces CDN. Attempting to do so may result in double the bandwidth charge without the CDN’s performance benefit.

If we include docs for DigitalOcean, we should recommend that people use either presigned URLs or the CDN, but not both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants