Commit 9caf41c5 authored by Diederik van der Boor's avatar Diederik van der Boor
Browse files

Update documentation for 1.1

parent eb7d8048
Changelog Changelog
========= =========
Version 1.1 (2017-02-07)
------------------------
* Allow to configure the storage class, using ``PRIVATE_STORAGE_CLASS``.
There are 3 storage classes available:
* ``private_storage.storage.files.PrivateFileSystemStorage`` - the original, default.
* ``private_storage.storage.s3boto3.PrivateS3BotoStorage`` - S3 bucket, based on django-storages_.
* ``private_storage.storage.s3boto3.PrivateEncryptedS3BotoStorage`` - S3 bucket with encryption.
* Added ``PrivateStorageView.get_path()`` method for easier reuse.
* Added ``PrivateStorageDetailView`` for easier reuse in projects.
* Added ``@deconstructible`` for storage classes.
* Added ``private_storage.servers.DjangoStreamingServer`` to support streaming data from non-filesystem storages.
* Dropped Django 1.6 support.
Version 1.0.2 (2017-01-11) Version 1.0.2 (2017-01-11)
-------------------------- --------------------------
...@@ -10,7 +27,7 @@ Version 1.0.2 (2017-01-11) ...@@ -10,7 +27,7 @@ Version 1.0.2 (2017-01-11)
Version 1.0.1 (2016-10-10) Version 1.0.1 (2016-10-10)
------------------------ --------------------------
* Fixed packaging NL translation * Fixed packaging NL translation
* Fixed error message for too large files. * Fixed error message for too large files.
...@@ -23,3 +40,6 @@ First PyPI release. ...@@ -23,3 +40,6 @@ First PyPI release.
The module design has been stable for quite some time, The module design has been stable for quite some time,
so it's time to show this module to the public. so it's time to show this module to the public.
.. _django-storages: https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html
...@@ -63,6 +63,41 @@ The ``PrivateFileField`` also accepts the following kwargs: ...@@ -63,6 +63,41 @@ The ``PrivateFileField`` also accepts the following kwargs:
Other topics Other topics
============ ============
Storing files on Amazon S3
--------------------------
The ``PRIVATE_STORAGE_CLASS`` setting can be redefined to point to a different storage class.
The default is ``private_storage.storage.files.PrivateFileSystemStorage``, which uses
a private media folder that ``PRIVATE_STORAGE_ROOT`` points to.
Define one of these settings instead:
.. code-block:: python
PRIVATE_STORAGE_CLASS = 'private_storage.storage.s3boto3.PrivateS3BotoStorage'
AWS_PRIVATE_STORAGE_BUCKET_NAME = 'private-files' # bucket name
This uses django-storages_ settings. Replace the prefix ``AWS_`` with ``AWS_PRIVATE_``.
The following settings are reused when they don't have an corresponding ``AWS_PRIVATE_...`` setting:
* ``AWS_ACCESS_KEY_ID``
* ``AWS_SECRET_ACCESS_KEY``
* ``AWS_S3_URL_PROTOCOL``
* ``AWS_S3_REGION_NAME``
* ``AWS_IS_GZIPPED``
All other settings should be explicitly defined with ``AWS_PRIVATE_...`` settings.
To have encryption either configure ``AWS_PRIVATE_S3_ENCRYPTION``
and ``AWS_PRIVATE_S3_SIGNATURE_VERSION`` or use:
.. code-block:: python
PRIVATE_STORAGE_CLASS = 'private_storage.storage.s3boto3.PrivateEncryptedS3BotoStorage'
Make sure an encryption key is generated on Amazon.
Defining access rules Defining access rules
--------------------- ---------------------
...@@ -142,9 +177,9 @@ For example: ...@@ -142,9 +177,9 @@ For example:
from django.db import models from django.db import models
from private_storage.fields import PrivateFileField from private_storage.fields import PrivateFileField
from private_storage.storage import PrivateStorage from private_storage.storage.files import PrivateFileSystemStorage
my_storage = PrivateStorage( my_storage = PrivateFileSystemStorage(
location='/path/to/storage2/', location='/path/to/storage2/',
base_url='/private-documents2/' base_url='/private-documents2/'
) )
...@@ -180,3 +215,6 @@ Contributing ...@@ -180,3 +215,6 @@ Contributing
This module is designed to be generic. In case there is anything you didn't like about it, This module is designed to be generic. In case there is anything you didn't like about it,
or think it's not flexible enough, please let us know. We'd love to improve it! or think it's not flexible enough, please let us know. We'd love to improve it!
.. _django-storages: https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html
...@@ -90,6 +90,7 @@ class PrivateStorageDetailView(SingleObjectMixin, PrivateStorageView): ...@@ -90,6 +90,7 @@ class PrivateStorageDetailView(SingleObjectMixin, PrivateStorageView):
def can_access_file(self, private_file): def can_access_file(self, private_file):
""" """
The authorization rule for this view. The authorization rule for this view.
By default it reuses the settings, but this should likely be redefined. By default it reuses the ``PRIVATE_STORAGE_AUTH_FUNCTION`` setting,
but this should likely be redefined.
""" """
return PrivateStorageView.can_access_file(private_file) return PrivateStorageView.can_access_file(private_file)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment