mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-24 02:08:36 +00:00
Merge pull request #224 from yvaucher/14.0-multi-tenancy
[14.0] attachment_s3: multi-tenancy use db name in bucket
This commit is contained in:
@@ -18,7 +18,7 @@ Configure accesses with environment variables:
|
|||||||
* ``AWS_REGION`` (required if using AWS services)
|
* ``AWS_REGION`` (required if using AWS services)
|
||||||
* ``AWS_ACCESS_KEY_ID``
|
* ``AWS_ACCESS_KEY_ID``
|
||||||
* ``AWS_SECRET_ACCESS_KEY``
|
* ``AWS_SECRET_ACCESS_KEY``
|
||||||
* ``AWS_BUCKETNAME``
|
* ``AWS_BUCKETNAME`` (optional {db} placeholder)
|
||||||
|
|
||||||
Read-only mode:
|
Read-only mode:
|
||||||
|
|
||||||
@@ -38,6 +38,18 @@ The System Parameter ``ir_attachment.storage.force.database`` can be customized
|
|||||||
force storage of files in the database. See the documentation of the module
|
force storage of files in the database. See the documentation of the module
|
||||||
``base_attachment_object_storage``.
|
``base_attachment_object_storage``.
|
||||||
|
|
||||||
|
Multi-tenancy
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Use the `{db}` placeholder to handle multi-tenancy.
|
||||||
|
|
||||||
|
On instances that hold multiple databases, it's preferable to have one bucket per database.
|
||||||
|
|
||||||
|
To handle this, you can insert the `{db}` placeholder in your bucket name variable ``AWS_BUCKETNAME``.
|
||||||
|
It will be replaced by the database name.
|
||||||
|
This will give you a unique bucketname per database.
|
||||||
|
|
||||||
|
|
||||||
Limitations
|
Limitations
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ class IrAttachment(models.Model):
|
|||||||
access_key = os.environ.get('AWS_ACCESS_KEY_ID')
|
access_key = os.environ.get('AWS_ACCESS_KEY_ID')
|
||||||
secret_key = os.environ.get('AWS_SECRET_ACCESS_KEY')
|
secret_key = os.environ.get('AWS_SECRET_ACCESS_KEY')
|
||||||
bucket_name = name or os.environ.get('AWS_BUCKETNAME')
|
bucket_name = name or os.environ.get('AWS_BUCKETNAME')
|
||||||
|
# replaces {db} by the database name to handle multi-tenancy
|
||||||
|
bucket_name.format(db=self.env.cr.dbname)
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
'aws_access_key_id': access_key,
|
'aws_access_key_id': access_key,
|
||||||
|
|||||||
Reference in New Issue
Block a user