Commits

Russell Moffitt committed 547b818

added s3botomulti settings to docs

Comments (0)

Files changed (2)

docs/backends/amazon-S3.rst

 Usage
 *****
 
-There are two backend APIs for interacting with S3. The first is the s3 backend (in storages/backends/s3.py) which is simple and based on the Amazon S3 Python library. The second is the s3boto backend (in storages/backends/s3boto.py) which is well-maintained by the community and is generally more robust (including connection pooling, etc...). s3boto requires the python-boto library.
+There are two backend APIs for interacting with S3. The first is the s3 backend (in storages/backends/s3.py) which is simple and based on the Amazon S3 Python library. The second is the s3boto backend (in storages/backends/s3boto.py) which is well-maintained by the community and is generally more robust (including connection pooling, etc...). s3boto requires the python-boto library.  Additionally, there is a subclass of s3boto called s3botomulti (in storages/backends/s3botomulti.py) which can be allows for multiple s3boto backends to be configured simulaneously via separate items in a dictionary in settings.  See the special s3botomulti settings below.
 
 Settings
 --------
 
     STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
 
+Settings for s3botomulti
+------
+
+``STORAGES_S3BOTO_MULTI``
+
+If you wish to use multiple s3boto backends (e.g., a separate config for your staticfiles and for your default file storage), you can use the s3botomulti backend without having to manually create a bunch of subclasses in a custom app.  The settings are generally the same as described above, except they are grouped in a dictionary in your settings.py as shown here with a named item for each separate backend you wish to use::
+
+    STORAGES_S3BOTO_MULTI = {
+        'media' : {
+            'AWS_ACCESS_KEY_ID' : 'key',
+            'AWS_SECRET_ACCESS_KEY' : 'secret',
+            'AWS_STORAGE_BUCKET_NAME' : 'mybucket',
+            'AWS_LOCATION' : 'media',
+        },
+        'static' : {
+            'AWS_ACCESS_KEY_ID' : 'key',
+            'AWS_SECRET_ACCESS_KEY' : 'secret',
+            'AWS_STORAGE_BUCKET_NAME' : 'mybucket',
+            'AWS_LOCATION' : 'static',
+        }
+    }
+
+This will automatically create a custom storage backend class named storages.backends.s3botomulti.S3BotoStorage_??? for each item in the settings dictionary, where ??? is replaced with each of the dictionary keys. For the samples settings above, you can refer to storages.backends.s3botomulti.S3BotoStorage_media and storages.backends.s3botomulti.S3BotoStorage_static.
+
+``DEFAULT_FILE_STORAGE and STATICFILES_STORAGE``
+
+Here is an example defining separate DEFAULT_FILE_STORAGE and STATICFILES_STORAGE::
+
+    DEFAULT_FILE_STORAGE = 'storages.backends.s3botomulti.S3BotoStorage_media'
+    STATICFILES_STORAGE = 'storages.backends.s3botomulti.S3BotoStorage_static'
+
 Fields
 ------
 

storages/backends/s3botomulti.py

 from django.conf import settings
 from storages.backends.s3boto import S3BotoStorage, SubdomainCallingFormat
 
-SETTINGS_DICT = getattr(settings, 'STORAGES_MULTI_S3BOTO', {})
+SETTINGS_DICT = getattr(settings, 'STORAGES_S3BOTO_MULTI', {})
 for s3store in SETTINGS_DICT:
     # Wrap class definition inside function closure to avoid conflicts between custom instances
     def init_s3boto_storage_custom():
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.