From 9ca3f876149028242cc43ef334af4e4746b2f5d0 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Thu, 13 Oct 2016 17:05:43 +0200 Subject: [PATCH] Remove the bin_size return When we return a bin_size (such as 28672), the web client does not accept it as as bin size and try to use it as value for the b64 src of the image. Though, returning the image as b64 in all cases does seem to be supported. --- attachment_s3/models/ir_attachment.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/attachment_s3/models/ir_attachment.py b/attachment_s3/models/ir_attachment.py index 2315933..c9e9313 100644 --- a/attachment_s3/models/ir_attachment.py +++ b/attachment_s3/models/ir_attachment.py @@ -43,7 +43,7 @@ class IrAttachment(models.Model): @api.depends('store_fname', 'db_datas') def _compute_datas(self): - bin_size = self._context.get('bin_size') + bin_size = self.env.context.get('bin_size') if self._s3_readonly(): for attach in self: # look first in db_datas in case a file has been modified @@ -165,10 +165,7 @@ class IrAttachment(models.Model): def _file_read_s3(self, bucket, fname, bin_size=False): filekey = bucket.get_key(fname) if filekey: - if bin_size: - read = filekey.size - else: - read = base64.b64encode(filekey.get_contents_as_string()) + read = base64.b64encode(filekey.get_contents_as_string()) else: # If the attachment has been created before the installation # of the addon, it might be stored on the filesystem.