Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Websites UFRPE
Django Private Storage
Commits
9caf41c5
Commit
9caf41c5
authored
Feb 07, 2017
by
Diederik van der Boor
Browse files
Update documentation for 1.1
parent
eb7d8048
Changes
3
Show whitespace changes
Inline
Side-by-side
CHANGES.rst
View file @
9caf41c5
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
README.rst
View file @
9caf41c5
...
@@ -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 Private
FileSystem
Storage
my_storage = PrivateStorage(
my_storage = Private
FileSystem
Storage(
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
private_storage/views.py
View file @
9caf41c5
...
@@ -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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment