attachment_s3: multi-tenancy use db name in bucket

Adds the possibility to insert `{db}` placeholder in the bucket name
that will be replaced by the database name to form a unique bucket
name per database.
This commit is contained in:
Yannick Vaucher
2021-05-18 17:09:38 +02:00
parent a182ea6542
commit 83e203c1aa
2 changed files with 15 additions and 1 deletions
+2
View File
@@ -55,6 +55,8 @@ class IrAttachment(models.Model):
access_key = os.environ.get('AWS_ACCESS_KEY_ID')
secret_key = os.environ.get('AWS_SECRET_ACCESS_KEY')
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 = {
'aws_access_key_id': access_key,