mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-24 08:47:40 +00:00
attachment_swift: multi-tenancy use db name in container
Adds the possibility to insert `{db}` placeholder in the container
name that will be replaced by the database name to form a unique
container name per database.
This commit is contained in:
@@ -146,6 +146,8 @@ class IrAttachment(models.Model):
|
||||
def _store_file_write(self, key, bin_data):
|
||||
if self._storage() == 'swift':
|
||||
container = os.environ.get('SWIFT_WRITE_CONTAINER')
|
||||
# replace {db} with the database name to handle multi-tenancy
|
||||
container = container.format(db=self.env.cr.dbname)
|
||||
conn = self._get_swift_connection()
|
||||
conn.put_container(container)
|
||||
filename = 'swift://{}/{}'.format(container, key)
|
||||
|
||||
Reference in New Issue
Block a user