Digital Ocean launched a new object storage service called Spaces. Are there any plans to support Spaces in this package?
You can use the existing S3BotoStorage class as their API is "the same" or close.
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' |
| 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.
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
@EdNutting Could you create a pull request to add this to the documentation? It would be very helpful.
Helped me immensely.
@sww314 Done 馃憤 (Good to hear people are finding this helpful.)
Closed by #521
Most helpful comment
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