Report this

What is the reason for this report?

Unable to interact with DigitalOcean CDN using boto3

Posted on January 12, 2021
Artur Kuchynski

By Artur Kuchynski

Machine Learning Engineer

In Wizart LLC we are using boto3 client for Python to interact with DigitalOcean Spaces.

After the CDN was enabled for our spaces, we become unable to access data stored in buckets.

For example, stored files can be accessed via the following CDN link:

https://wizart-storage-data-dev.fra1.cdn.digitaloceanspaces.com/interiors/uploaded/images/07IRgHJ2PFhVqVrJDCIpzhghqe4TwK1cSSUXaC4T.jpeg

But boto3 SDK generates URLs like this one given in the form:

https://fra1.cdn.digitaloceanspaces.com/wizart-storage-data-dev/interiors/uploaded/images/07IRgHJ2PFhVqVrJDCIpzhghqe4TwK1cSSUXaC4T.jpeg

which seems to be an invalid CDN URL for DigitalOcean Spaces.

When CDN is not specified - the file is accessible with no problems:

https://fra1.digitaloceanspaces.com/wizart-storage-data-dev/interiors/uploaded/images/07IRgHJ2PFhVqVrJDCIpzhghqe4TwK1cSSUXaC4T.jpeg


Is any workaround can be applied in our case?


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Heya,

Just came across this answer and decided to write some general guidelines for anyone who comes across this in the future despite the old question.

Boto3 uses the standard AWS format, but it seems the support for it isn’t fully there yet with DigitalOcean.

A possible workaround is to create URLs manually instead of relying on boto3 to create the URLs. You need to use the following pattern: https://your-space-name.your-region.digitaloceanspaces.com/your-object-key Instead of: https://your-region.your-space-name.digitaloceanspaces.com/your-object-key

If this doesn’t resolve your issue, I recommend reaching out to DigitalOcean support directly through the website.

For more information about working with DigitalOcean Spaces and CDNs, check out the DigitalOcean Spaces Documentation.

Hope that this helps!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.