mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-24 02:08:36 +00:00
[FIX] attachment_s3: Close fileobjects after usage
This commit is contained in:
committed by
Guewen Baconnier
co-authored by
Guewen Baconnier
parent
c89bfc83e0
commit
11c90c5a17
@@ -124,7 +124,7 @@ class IrAttachment(models.Model):
|
|||||||
)
|
)
|
||||||
if bin_size:
|
if bin_size:
|
||||||
return bucket.Object(key).content_length
|
return bucket.Object(key).content_length
|
||||||
res = io.BytesIO()
|
with io.BytesIO() as res:
|
||||||
bucket.download_fileobj(key, res)
|
bucket.download_fileobj(key, res)
|
||||||
res.seek(0)
|
res.seek(0)
|
||||||
read = base64.b64encode(res.read())
|
read = base64.b64encode(res.read())
|
||||||
@@ -143,7 +143,7 @@ class IrAttachment(models.Model):
|
|||||||
if location == 's3':
|
if location == 's3':
|
||||||
bucket = self._get_s3_bucket()
|
bucket = self._get_s3_bucket()
|
||||||
obj = bucket.Object(key=key)
|
obj = bucket.Object(key=key)
|
||||||
file = io.BytesIO()
|
with io.BytesIO() as file:
|
||||||
file.write(bin_data)
|
file.write(bin_data)
|
||||||
file.seek(0)
|
file.seek(0)
|
||||||
filename = 's3://%s/%s' % (bucket.name, key)
|
filename = 's3://%s/%s' % (bucket.name, key)
|
||||||
|
|||||||
Reference in New Issue
Block a user