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

Digital Ocean Spaces support #395

Closed
paramono opened this issue Sep 23, 2017 · 7 comments
Closed

Digital Ocean Spaces support #395

paramono opened this issue Sep 23, 2017 · 7 comments

Comments

@paramono
Copy link

Digital Ocean launched a new object storage service called Spaces. Are there any plans to support Spaces in this package?

@destos
Copy link

destos commented Oct 6, 2017

You can use the existing S3BotoStorage class as their API is "the same" or close.

@EdNutting
Copy link
Contributor

EdNutting commented Oct 18, 2017

Here's some example config for you - this works with current stable version of Django storages:

Name Description Example value
AWS_STORAGE_BUCKET_NAME The name of the storage bucket. mysite
AWS_S3_ENDPOINT_URL The endpoint url excluding the bucket name. https://nyc3.digitaloceanspaces.com
AWS_S3_OBJECT_PARAMETERS Default params for objects. { 'CacheControl': 'max-age=86400' }
AWS_LOCATION The folder within the space to store files. mysite
AWS_S3_SIGNATURE_VERSION Signature version. DigitalOcean only support v2 for pre-signed urls. s3=s3v2 (Version 2), s3v4=s3v4 (Version 4)
AWS_STATIC_LOCATION The folder within the space to store static files. '%s/static' % AWS_LOCATION
STATICFILES_STORAGE The storage backend to use for static files. 'mysite.storage_backends.StaticStorage'
STATIC_URL The base URL for generating URLs to static files included in rendered pages. "https://%s/%s/" % (AWS_S3_ENDPOINT_URL, AWS_STATIC_LOCATION)
AWS_PUBLIC_MEDIA_LOCATION The folder within the space to store public media files. '%s/media/public' % AWS_LOCATION
DEFAULT_FILE_STORAGE The storage backend to use for public media files. 'mysite.storage_backends.PublicMediaStorage'
AWS_PRIVATE_MEDIA_LOCATION The folder within the space to store private media files. '%s/media/private' % AWS_LOCATION
PRIVATE_FILE_STORAGE The storage backend to use for private media files. 'mysite.storage_backends.PrivateMediaStorage'

Private Configuration

Name Description
AWS_ACCESS_KEY_ID The access key for the storage API. Although this can be public, it's useful to store it with the secret key to force the server admin to think about / change it, at the same time as changing the secret.
AWS_SECRET_ACCESS_KEY The secret key for the storage API. Never reveal this to anyone :)

You can use the models/storage backends/views/etc from the blog post below to create a test site (called mysite) to try this out. Testing locally using runserver works.

https://simpleisbetterthancomplex.com/tutorial/2017/08/01/how-to-setup-amazon-s3-in-a-django-project.html

See the folder "s3-example-public-and-private" from the GitHub repo for that blog post: https://github.com/sibtc/simple-s3-setup

To get the access key and secret key, follow the getting started guide from DigitalOcean: https://www.digitalocean.com/community/tutorials/managing-access-to-digitalocean-spaces#option-1-%E2%80%94-sharing-access-to-spaces-with-access-keys

Hope this helps!
Ed

@sww314
Copy link
Contributor

sww314 commented Jul 3, 2018

@EdNutting Could you create a pull request to add this to the documentation? It would be very helpful.

@sixthgear
Copy link

Helped me immensely.

@EdNutting
Copy link
Contributor

@sww314 Done 👍 (Good to hear people are finding this helpful.)

@sww314
Copy link
Contributor

sww314 commented Jul 12, 2018

Closed by #521

@lifenautjoe
Copy link

FYI Signatures do not work using the Spaces CDN

#944

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

No branches or pull requests

7 participants
@sixthgear @destos @sww314 @EdNutting @paramono @lifenautjoe and others