[IMP] attachment_s3: Consider bin_size context key

When bin_size context key is set, read operations on attachments
are supposed to return the size of the attachment and not its content
This commit is contained in:
Akim Juillerat
2020-06-22 07:46:05 +02:00
committed by Guewen Baconnier
co-authored by Guewen Baconnier
parent fd335d89be
commit c89bfc83e0
+2
View File
@@ -122,6 +122,8 @@ class IrAttachment(models.Model):
bucket.meta.client.head_object(
Bucket=bucket.name, Key=key
)
if bin_size:
return bucket.Object(key).content_length
res = io.BytesIO()
bucket.download_fileobj(key, res)
res.seek(0)