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-27 18:16:34 +02:00
parent 8424af433b
commit 09361a9c3e
2 changed files with 15 additions and 1 deletions
+2
View File
@@ -56,6 +56,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,